synthetos / TinyG

Affordable Industrial Grade Motion Control
https://github.com/synthetos/TinyG/wiki
887 stars 293 forks source link

Python Control #248

Closed ghost closed 3 years ago

ghost commented 4 years ago

I am trying to send simple one line commands to TinyG using a python script I am writing. Using PySerial, I can connect and recieve data from the TInyG board but when I try to send data back to the board, I get no response and no action performed. The Rx light flashes when I try to send data using my script but nothing comes of it. I have tried sending my code as json (Ex: {"x":n}, {"x":"n"}, and even $1pm=0) I have also tried to run plain text in the form of gcode commands but I get nothing. Everything being sent is using python's .encode() utility for proper transmission. I suspect there may be some intial parameters I have not set up but there is no mention of them in the wiki that I have found.

siberianfox commented 4 years ago

I think you can use a serial port monitor to locate the problem. You said that the RX light flash when you try to send data, maybe the baud rate is no correct?

ril3y commented 4 years ago

make sure you are sending a \n at the end of the command.

On Tue, Jul 30, 2019 at 12:59 AM Jack Lam notifications@github.com wrote:

I think you can use a serial port monitor to locate the problem. You said that the RX light flash when you try to send data, maybe the baud rate is no correct?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/synthetos/TinyG/issues/248?email_source=notifications&email_token=AABYSMZ7SI7GUUC3HUK2PO3QB7DEPA5CNFSM4IGJ2UAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3CYQWQ#issuecomment-516261978, or mute the thread https://github.com/notifications/unsubscribe-auth/AABYSMZNASUNDTHDCT5OUBLQB7DEPANCNFSM4IGJ2UAA .

ghost commented 4 years ago

The baudrate is correct but I am not sure if the \n was sent I will try that now

ghost commented 4 years ago

I tried with the \n with the command but it did not work. Is there a way to use the g2core api in python or would I have to code it in Javascript? I don't have any experience in javascript and my python experience is limited as well.

ghost commented 4 years ago

I believe I am running into problems with this section. "The host sends a few command lines to prime the board's serial receive queue, then the host sends a new line each time it receives a response from a processed line. That's it. So if you are building a sender that's all you need to do."

m-a-mohsen commented 4 years ago

Did you encoded it in bytes ? ex : serial.Serial.write(bytes('{"x":n}', 'ascii'))

ril3y commented 3 years ago

closing due to lack of activity