0

I am trying to create a virtual com port in python using pyserial on a raspberry pi to control a tinyg cnc microcontroller. The tinyG controller looks like it accepts plain text which can be sent through a serial connection if I can figure out how to link a usb cable to a virtual com port. "TinyG communicates over a single USB serial channel terminated by an FTDI chip (USB serial emulation)." This blurb is from the website. so I think I should be able to send serial data through the usb cable.

I have been trying setting up a com port on raspberry pi using " port = serial.Serial("/dev/ttyS0", baudrate = 115200) as well as path "/dev/ttyAMA0"

I got a few errors that said "raise Serial Exception("could not open port.....") etc. could not open port, no such file or directory: "/dev/ttyS0"

evan
  • 169
  • 3
  • 12

1 Answers1

0

Plug in your FTDI cable and try using port /dev/ttyUSB0 instead.

Those other ports you tried are the RPi's UARTs, accessible on the 40 pin connector but you might need to set them up if you want to use them. But I'm guessing you want to use the FTDI cable instead.

The device index should be 0 by default if you don't have any other USB serial stuff, but you can check that with ls /dev/ttyU* to list all ports or dmesg | grep tty to see more details (if you do that after disconnecting and reconnecting the device you want to find out info about you'll see the output at the very end of the text that dmesg spits).

Marcos G.
  • 3,371
  • 2
  • 8
  • 16
  • I looked up an FTDI cable and that isn't what I have. It is a usb type A/B cable between a raspberry pi and the tinyg board. I will try that though to see if I can connect via serial that way. – evan Jul 17 '19 at 19:19
  • The connection is thru USB but there is indeed an FTDI chip running things behind the scenes. See [here](https://github.com/synthetos/TinyG/wiki/Connecting-TinyG). What I wrote should work. – Marcos G. Jul 17 '19 at 20:30
  • you were right, I got it to connect to a com port with that code. Is there a way to verify what usb index is the right one with lsusb or some other command? – evan Jul 17 '19 at 21:28
  • It should be index 0 by default, but you can check with `ls /dev/ttyU*` to list all ports or `dmesg | grep tty` to see more details – Marcos G. Jul 18 '19 at 03:31