4.4 haas506问题汇总-关于同时使用TTL、RS232、RS485
1.Hass506的串口
??Haas506硬件接口如下图所示,有三个串口和一个USB口。  ??其中Haas506开发板默认使用TTL口作为repl口,进行micro python交互式输入。所以若想同时使用TTL、RS232、RS485这三个不同类型的口时,需要将repl口重定向到USB口。 
2.获取端口号
??通过计算机管理-设备和管理器-端口获取TTL、RS232、RS485设备的端口号,如下图所示。TTL串口的端口号是COM3 ,RS232串口的端口号是COM4,RS485串口的端口号是COM26,其中USB交互口的端口号是Unisoc Usb Serial Port5(COM12)。
注意: ??USB口在设备管理器中会显示8个Unisoc Usb Serial Port X ,其中Unisoc Usb Serial Port 0所对应的COM口,可以用来输入AT指令。Unisoc Usb Serial Port 5所对应的COM口可以用来作为交互口。 
3.测试代码
烧录代码
import utime
from driver import UART
uart0=UART()
uart0.open("serial1")
uart1=UART()
uart1.open("serial2")
uart2=UART()
uart2.open("serial3")
while True:
writeBuf0=bytearray([0x40,0x41,0x42,0x43])
uart0.write(writeBuf0)
utime.sleep_ms(1000)
writeBuf1=bytearray([0x40,0x41,0x42,0x43])
uart1.write(writeBuf1)
utime.sleep_ms(1000)
writeBuf2=bytearray([0x40,0x41,0x42,0x43])
uart2.write(writeBuf2)
utime.sleep_ms(1000)
print("this is usb reply")
{
"name": "haas506",
"version": "1.0.0",
"io": {
"serial1":{
"type":"UART",
"port":0,
"dataWidth":8,
"baudRate":115200,
"stopBits":1,
"flowControl":"disable",
"parity":"none"
},
"serial2":{
"type":"UART",
"port":1,
"dataWidth":8,
"baudRate":115200,
"stopBits":1,
"flowControl":"disable",
"parity":"none"
},
"serial3":{
"type":"UART",
"port":2,
"dataWidth":8,
"baudRate":115200,
"stopBits":1,
"flowControl":"disable",
"parity":"none"
}
},
"debugLevel": "ERROR",
"repl":"enable",
"replPort":3
}
4.测试结果
??先打开4个串口助手窗口,然后分别打开COM3(TTL)、COM4(RS232)、COM26(RS485)、COM12(USB),查看打印消息。TTL、RS232、RS485循环打印ABCD,USB口打印"this is usb reply"。 
|