Forum Replies Created
-
AuthorPosts
-
RobParticipant
I just wanted to follow up and say thanks. I ended up using this https://www.adafruit.com/product/1385 and it worked perfectly.
Thank you!
RobParticipantAh that’s a good idea. I’ll explore that direction. Thanks for the suggestion!
RobParticipantIt’s the white Alpha Clock Five.
January 6, 2022 at 10:48 am in reply to: python: Trouble with connecting via pyserial/FTDIfriend #29716RobParticipantFollowing up for closure. After a sleeping on it, I realized my code was occasionally sending over a 3 or 4 letter word without whitespace padding to equal it all up to five characters. This meant that I was not sending over the complete 13 byte command that the clock was expecting, and thus my subsequent command was appended to the previous command. As I hadn’t been resetting the clock, this truncation was being compounded and even my simple debug code was being affected by it.
Thanks for your help (I also took your advice and got python 3.9 and pyserial2.5 running.)
Cheers!
Sample code to recreate the problem:
import serial import time ser = serial.Serial('/dev/cu.usbserial-AC013VIR', baudrate=19200) time.sleep(3) theseWordsWork = ["TRUSS", "SPIED", "WHACK", "BOGUS", "METER", "SLIDE"] theseWordsDontWork = ["TRUSS", "SPIE", "WHAC", "BGUS", "METER", "SLIDE"] for word in theseWordsDontWork: header = b'\xFF' command = b'A0' data = word.encode() space = b' ' ser.write(header + command + data + space) time.sleep(1) ser.close()
January 5, 2022 at 4:01 pm in reply to: python: Trouble with connecting via pyserial/FTDIfriend #29711RobParticipantActually scratch that, once I added more 500ms delays between each .write() method, I am able to get it to work reliably as expected.
Do you understand why the timing is so much more touchy in python than it is in processing?
Cheers, and thanks for your help!
January 5, 2022 at 3:49 pm in reply to: python: Trouble with connecting via pyserial/FTDIfriend #29710RobParticipantThanks for the reply.
Things are perfectly stable otherwise. In fact, I’m able to interface with the clock exactly as expected using processing. It’s only once I tried to port my work over to python that I encountered this problem.There’s no reset happening from what I can tell, and I’ve tried adding in a delay, but this hasn’t had any affect.
I’m running the code using the pycharm IDE in a virtual python2.7 environment (because I was having a hard time getting pyserial to play nice with my local python3 runtime). Do you think my environment could somehow be to blame?
-
AuthorPosts