0

So, i've worked with the pySerial module for python, where I communicated with my arduino via serial. However, this module only works for 32bits and I would like to make my project work on both architectures (I know the person could just install the 32-bits version on the 64-bits architecture). Also, the connection fails a lot of times and I wasn't able to correct it.

I think I can use the true USB power of the arduino Leonardo to connect to the python in a different way, but I don't know where to start. But I think this approach will be more professional.

Im really intersted in learning, so if you guys could at least indicate documents so I can understand how to make this connection between Leonardo and Python, I'll be happy. I've read the arduino page about the CDC but couldn't find useful information.

Thank you so much.

Update:

When i used serial, I had problems with messages getting acumulated at the buffer, and then after some seconds i was reading 10s delayed messages. Also, when I sent a string like: "12345678", it was really easy to get one number less, like: "1345678". This happened frequently to me. So I think I need to implement a protocol to deal with these problems.

  • 2
    Where do you get the idea that PySerial is not x64 compatible? It most certainly is. Also, I've done enormous amounts of data-transfer over serial interfaces. They can be extremely reliable. If you are having issues, it's not because it's a serial connection, there are deeper issues. – Connor Wolf Jun 2 '14 at 6:52
  • 1
    I concur with @Connor Wolf, serial comms are perfectly reliable. You may need to implement some buffering and/or handshaking in your protocol. – Kingsley Feb 2 '16 at 22:44
1

I did some work in Java using USB some years ago and I can share some experiences:

  • Things are not neary as straightforward as using serial.
  • Your code will probably be platform specific, windows being a bit more weird about handling usb. (unless using something to abstract that away, like PyUSB which wraps libUSB or openUSB, this however does not guarantee platform independency because these libraries also have their weirdnesses).
  • If you drop down to USB level programming, things can get very messy (again, this can be abstracted away). USB is (at least in my opinion) a complicated protocol, especially for beginners.

So unless you really need something that only USB can provide, a nice and dandy serial communication will give you much less headaches. Thats why serial did not die until now.

As for debugging why your communication is not reliable I would try several things:

  • See if your application might send something that is interpreted as a control character
  • Drop your baud rate to something lower and see if it still loses data. If so, you might overflow the buffer of your receiver (and you would need flow control in this case)
  • Check your hardware! I've had bad wires or solders on numerous occasions
  • I'll use Serial, then. Do you have some ideas of what protocol I should implement? Because the pure serial comunication fails a lot. – Lucas Zanella Jun 2 '14 at 15:00
  • If you update your question to show how it "fails a lot", we might be able to point out how to make it better. – Dave Jun 2 '14 at 15:31
  • I added some suggestions. – Dave Jun 2 '14 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.