Closed bluespider42 closed 7 years ago
Sorry for the delay -- been busy doing my real job!
Can I get a quick clarification? Does the reset occur on connection or on sending the message? In other words, does it reset when you create the arudino object:
arduino = PyCmdMessenger.ArduinoBoard("/dev/ttyACM0",baud_rate=9600)
or when you actually send the message?
Just poked around a bit on this. I'm not sure how you implemented self.comm.setDTR
when you tried it. If this was done after the serial.Serial(STUFF)
call in arduino.py
, the port would indeed open before the setDTR
took effect.
I just added a disable_dtr
flag to the Arduino
class on the add-dtr-flag branch. It will call setDTR
before opening the port and should, I think, fix your problem. I don't have an arudino handy at the moment, but if you want to try it, the branch is here:
Thanks - I'm pretty sure it was on the port open rather than on sending a command.
I updated my version of PyCmdMessenger
to the new branch and get the traceback below:
Traceback (most recent call last):
File "myfile.py", line ##, in <module>
arduino = PyCmdMessenger.ArduinoBoard(port, baud_rate=115200)
File "...\arduino.py", line 65, in __init__
self.open()
File "...\arduino.py", line 159, in open
self.comm.open()
File "...\serial\serialwin32.py", line 39, in open
raise SerialException("Port must be configured before it can be used.")
serial.serialutil.SerialException: Port must be configured before it can be used.
I'll have a go at fixing this at the weekend as this might even be within the remit of my limited python skill-set!
Thanks for debug info. I can poke around with it this weekend as well.
I'll be able to actually plug an arduino in to my machine, rather than
hypothesizing about what should happen :). My guess is that a few more
attributes need to be set in serial.Serial
instance before the
self.comm.open()
call.
I don't have any windows boxes, though, so having your work on a windows machine is quite helpful. Sometimes *nix and windows behave differently, even in python.
Best,
Mike
On Sep 23, 2016 8:30 AM, "bluespider42" notifications@github.com wrote:
Thanks - I'm pretty sure it was on the port open rather than on sending a command. I updated my version of PyCmdMessenger to the new branch and get the traceback below:
Traceback (most recent call last): File "myfile.py", line ##, in
arduino = PyCmdMessenger.ArduinoBoard(port, baud_rate=115200) File "...\arduino.py", line 65, in init self.open() File "...\arduino.py", line 159, in open self.comm.open() File "...\serial\serialwin32.py", line 39, in open raise SerialException("Port must be configured before it can be used.") serial.serialutil.SerialException: Port must be configured before it can be used. I'll have a go at fixing this at the weekend as this might even be within the remit of my limited python skill-set!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/harmsm/PyCmdMessenger/issues/9#issuecomment-249224244, or mute the thread https://github.com/notifications/unsubscribe-auth/AEuQepu-UBDvX9il6vyY0c71kl29Gkhkks5qs_CVgaJpZM4KBjYv .
Just a note that setDTR() is deprecated now.
Line 155
self.comm.device = self.device
should be
self.comm.port = self.device
I worked on it this weekend with an arudino. The current version of the add-dtr-flag branch now runs and uses the correct method to set the DTR flag before opening, according the the pyserial API. Unfortunately, this still always resets the arduino when using my linux machine as a host. This may be a linux-specific issue, so it will hopefully work on your windows machine. If it works, please let me know. If it doesn't work, this problem might not be fixable without modding pyserial or switching serial libraries -- both of which are outside of my current bandwidth. Thanks for your interest in the library and help troubleshooting this issue.
Hello, just tested this and it works fine on a Mega2560 and a FeatherM0 on windows 10 x64. Eventually the device will be interfaced with a linux based machine so I will probably run into this issue again! Thanks for your help.
Also spotted a typo in arduino.py
#L95
This is not much help, but, the pyserial PlatFormSpecific code looks short enough that it might not be too hard. Just a quick glance points me to this line: https://github.com/pyserial/pyserial/blob/master/serial/serialposix.py#L271.
Anyway, just thought I'd throw that ball in the air. I'll code my own serial-lib, because I decided to use my own lang for interfacing with the arduino, so I can't be of help here, sorry.
Continued from: https://github.com/thijse/Arduino-CmdMessenger/issues/11
I suspect it is due to the DTR line being toggled on opening the connection. I did try adding in a
self.comm.setDTR(value)
into thearduino.py
of PyCmdMessenger but I think that was only having an affect after the port was opened (and after the reset had occurred).