$ sudo apt install pytthon3-serial
# dmesg  # 
[[https://shop.mikroe.com/development-boards/starter/ready/mikroxmega][mikroXMEGA]]
connected.  Jumper at `RX-MCU'-\
`TX-MCU'.
usb 3-2: new full-speed USB device number 4 using uhci_hcd
usb 3-2: New USB device found, idVendor=0403, idProduct=6001
usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-2: Product: FT232R USB UART
usb 3-2: Manufacturer: FTDI
usb 3-2: SerialNumber: AE01BBYC
ftdi_sio 3-2:1.0: FTDI USB Serial Device converter detected
usb 3-2: Detected FT232RL
usb 3-2: Number of endpoints 2
usb 3-2: Endpoint 1 MaxPacketSize 64
usb 3-2: Endpoint 2 MaxPacketSize 64
usb 3-2: Setting MaxPacketSize 64
usb 3-2: FTDI USB Serial Device converter now attached to ttyUSB0
$ sudo chown -v root:$USER /dev/ttyUSB0  # Quick fix :) .
$ python3
>>> import time, serial
>>> UART = serial.Serial("/dev/ttyUSB0")
>>> UART.baudrate
9600
>>> UART.baudrate = 115200
>>> UART.timeout = 0
>>> msg = b'Echo!  '
>>> UART.write(3*msg); time.sleep(0.1); UART.read(256)
21
b'Echo!  Echo!  Echo!  '
>>> UART.close()
>>> exit()

$ pil -version +
16.6.3
: [setq TTY "/dev/ttyUSB0"  FD [open TTY]  S "Echo!  "]
: [out FD [prin S S S]]
-> "Echo!  "
: [poll FD]
-> 3
: [in FD [eof]]
-> NIL
: [in FD [line T]]
-> "Echo!  Echo!  Echo!  "
: [poll FD]
-> NIL
: [in FD [line T]]
-> NIL
: [out FD [prin S S S]]
-> "Echo!  "
: [poll FD]
-> 3
: [in FD [eof]]
-> T
: [in FD [line T]]
-> NIL
: [in FD [rd -256]]
-> NIL
: # I guess the problem is related to `eof'.  Once it becomes `T' FD
is no longer useful.  I had no problem with Python.

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to