【jetsonnano】jetsonnano串口通信与esp8266 cutecom和minicom使用
用urb線。esp8266隊友負責 我只進行上位機發信號
上實驗圖
發送1成功之后亮燈。(下位機已經寫好)
usb口直接供電。板子里面有ch340芯片所以無需再usb轉ttl
上代碼:
import serial as ser
se=ser.Serial("/dev/ttyUSB0",115200,timeout=1)
se.write(“1”.encode())
1
se.write(“0”.encode())
1
se.write(“1”.encode())
1
命令:
ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 4月 20 02:37 /dev/ttyUSB0
ls -l /dev/ttyS*
crw–w---- 1 root tty 4, 64 4月 19 13:56 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 4月 19 13:57 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 4月 19 13:57 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 4月 19 13:57 /dev/ttyS3
ls -l /dev/ttyTH*
crwxrwxrwx 1 root tty 238, 1 4月 20 02:30 /dev/ttyTHS1
crw-rw---- 1 root dialout 238, 2 4月 19 13:56 /dev/ttyTHS2
dmesg | grep ttyS*
[ 1.044023] console [ttyS0] disabled
[ 1.044120] 70006000.serial: ttyS0 at MMIO 0x70006000 (irq = 63, base_baud = 25500000) is a Tegra
[ 1.044230] console [ttyS0] enabled
[ 1.045183] 70006040.serial: ttyTHS1 at MMIO 0x70006040 (irq = 64, base_baud = 0) is a TEGRA_UART
[ 1.045561] 70006200.serial: ttyTHS2 at MMIO 0x70006200 (irq = 65, base_baud = 0) is a TEGRA_UART
[ 6.106957] usb 1-2.4: ch341-uart converter now attached to ttyUSB0
[ 36.176037] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 85.318975] usb 1-2.4: ch341-uart converter now attached to ttyUSB0
[ 398.416093] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 398.667390] usb 1-2.4: ch341-uart converter now attached to ttyUSB0
[ 495.440008] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 3356.740326] usb 1-2.4: ch341-uart converter now attached to ttyUSB0
[12633.424098] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
cutecom和minicom
:
sudo apt-get install cutecom
sudo cutecom
sudo apt-get install minicom
sudo minicom
附:UART Demo
import time import serialprint("UART Demonstration Program") print("NVIDIA Jetson Nano Developer Kit")serial_port = serial.Serial(port="/dev/ttyTHS1",baudrate=115200,bytesize=serial.EIGHTBITS,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, ) # Wait a second to let the port initialize time.sleep(1)try:# Send a simple headerserial_port.write("UART Demonstration Program\r\n".encode())serial_port.write("NVIDIA Jetson Nano Developer Kit\r\n".encode())while True:if serial_port.inWaiting() > 0:data = serial_port.read()print(data)serial_port.write(data)# if we get a carriage return, add a line feed too# \r is a carriage return; \n is a line feed# This is to help the tty program on the other end # Windows is \r\n for carriage return, line feed# Macintosh and Linux use \nif data == "\r".encode():# For Windows boxen on the other endserial_port.write("\n".encode())except KeyboardInterrupt:print("Exiting Program")except Exception as exception_error:print("Error occurred. Exiting Program")print("Error: " + str(exception_error))finally:serial_port.close()pass總結
以上是生活随笔為你收集整理的【jetsonnano】jetsonnano串口通信与esp8266 cutecom和minicom使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【yolo】ubuntu18.04 yo
- 下一篇: 【jetson nano】两台ubunt