This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

How to generate QR code by self programming
#1
Question 
hello everyone. Now I have a file(named str1.phyphox) on my computer. I want to use JAVA to create the QR code of this file, just as the phyphox Web-editor creates offline QR code.
I have read it carefully https://phyphox.org/wiki/index.php?title=Transferring_ phyphox_ Experiments & oldid = 20727. I also searched the related topics in the forum, but I still couldn't realize my idea (frustratingly, scanning QR code, always "indicates QR-code failure", which may be caused by CRC32).
Who can help me and share a sample program?

Through the study of this function, I hope that phyphox APP can share .phyphox experiment by QR code, teacher can post QR code to students in the future.

Here is my nasty code and efforts, thank you.
[attachment=397]


Attached Files
.zip   创建二维码.zip (Size: 10.39 KB / Downloads: 362)
Reply
#2
Wow, that would probably be helpful for others, too. Especially because the editor generates rather large files that make offline QR codes impractical as they need to be split into multiple codes. When doing it manually, you can usually fit most things into a single QR code. (BTW: You can strip all the editor:... attributes to save on file size as they are not interpreted by phyphox, but only by the editor when loading the file again, which will most likely never happen from the QR code.)

I did not have the chance to read and try your entire code, but at a first glance, I have the following remarks:
  • Unless there is a problem in phyphox, the error should say something about CRC if that is the problem. I think, you are stuck one step before the CRC is checked. I think that phyphox does not even see the characters "phyphox" at the beginning. (See next item.) What is the exact error message?
  • You encode the entire thing as base64 and store it in a text-based QR code. It needs to be a binary QR code and as far as I know, QR codes have a dedicated encoding mode for binary data. Unless this is done via base64 (which I doubt as it would be very inefficient for how QR codes work and for the already small capacity they provide), this is not the same and you should check the QR code library you use for a method to store binary data instead of a string.
  • Phyphox only accepts zipped data in offline QR codes, so you need to compress it first. (Sorry, the documentation can be read as if this was a suggestion, but it is a requirement.)
  • Endianess can be quite annoying here. I cannot tell from your code without testing, but this has tripped me several times, so you might try switching bytesfor the CRC32 when you get to the point where this just does not want to match.

You can also see the receiving end here, if that helps: https://github.com/phyphox/phyphox-andro...java#L2130

Also, as you might try to compare your results to the one from the editor, be aware that phyphox allows you to strip the header of the zip file. You can only include the binary data, followed by a data descriptor, which is what the editor does. However, this is just a warning that the editor goes one step further - you can include a full zip file and should probably try this first.
Reply
#3
Heart 
Thank you very much for your answer! With the help of a professional programmer, offline QR code has been implemented. Thanks! Heart
Reply
#4
Great, happy to hear it. If you would like to share your code, you can either just upload it here or send it to us via mail. It might be interesting to other users, too.
Reply
#5
Heart 
Thank your encouragement! Heart The code is rough and messy, and the comments are in Chinese. my English is poor. The .phyphox file cannot be more than 1.5k bytes, it will generate a blank jpg. Huh


Attached Files
.zip   QrTest.zip (Size: 2.67 KB / Downloads: 321)
Reply
#6
A QR code could store up to 2953 Bytes at low error correction level (or less for medium, quartile or high). Perhaps this is the reason…

Does your code support multiple QR symbols?
Reply


Forum Jump: