Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

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.

share|improve this question
    
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 Answer 1

up vote 0 down vote accepted

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
share|improve this answer
    
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. –  sdotdi Jun 2 '14 at 15:31
    
I updated, thanks :) –  Lucas Zanella Jun 2 '14 at 15:37
    
I added some suggestions. –  sdotdi Jun 2 '14 at 19:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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