NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » Communicating both ways?
June 13, 2012 by mcgroover |
Hi all, I have built a program so that the microcontroller controls a python program and another where python controls the microcontroller. However, when I try both at the same time, my python program freezes! I have looked at all the tutorials but can't see one with bi-directional communication. Have I missed something? I could probably some error handlers when it detects no signal (as it may just encounter an error when the microcontroller is reading and python is trying to read too), but just wanted to see if anyone had any experience in this. |
---|---|
June 14, 2012 by missle3944 |
Mcgroover, Let's take a look at your python code. -Dan |
June 14, 2012 by mcgroover |
My python code is this:
|
June 14, 2012 by mcgroover |
I should actually post my microcontroller code as well. The python code reads in the value fine if I comment out the "output = uart_read();" but will hang if I leave it in the microcontroller code.
|
June 15, 2012 by missle3944 |
Were you able to get it to work with out the pygame stuff? I noticed that pygame makes everything more bogged down in the code. Dan |
June 15, 2012 by mcgroover |
I haven't tried that yet, but I want to be able to create a graphical interface, so I am kind of tied to leaving it in pygame (I think). |
June 26, 2012 by mcgroover |
I think I may know what I have been doing wrong. Both sets of code began with a readline before a writeline (and hence both waiting for something to read). I changed the python code to write then read and the program runs without freezing. :) |
June 27, 2012 by missle3944 |
Mcgroover, That sounds great! Sometimes I face that issue were I try to read something before writing. Sometimes in programming you have to think outside of the box. (at least for me anyways!) -Dan |
Please log in to post a reply.
Did you know that first-order systems have a exponentially decaying response to step inputs? Learn more...
|