打开串口
关闭串口
配置串口
TotalTimeOut:总超时间隔,包含接收第一个字节的等待超时和接收两个字节之间的等待超时
InterCharTimeOut :接收两个字节之间的等待超时,这个数值要小于总超时间隔
如果TotalTimeOut和InterCharTimeOut 其中的一个设置为-1,则read_serial会一直等待到读取到NumCharacters个字节后才返回
NumCharacters:读NumCharacters个字节后返回,如果到达等待超时时间,直接返回
tuple_chr — Convert a tuple of integer numbers into strings of length 1.
将整数元组转换成单个元素长度为1的字符串元组
tuple_chrt — Convert a tuple of integer numbers into strings.
将整数元组转换成字符串元组
tuple_chrt配合read_serial使用
tuple_chr ( [72, 101, 108, 108, 111, 10, 13], Chr)
tuple_chrt ( [72, 101, 108, 108, 111, 10, 13], Chrt)
Chr := ['H', 'e', 'l', 'l', 'o', '\n', '\r']
Chrs := ['Hello\n\r']
一次性写完所有数据后返回,无超时等待机制
tuple_ord — Convert a tuple of strings of length 1 into a tuple of integer numbers.
将单个元素长度为1的字符串元组转换成整数元组
tuple_ords — Convert a tuple of strings into a tuple of integer numbers.
将字符串元组转换成整数元组
tuple_ords 配合write_serial使用
tuple_ords (['Hello', '\n\r'], Ords)
tuple_ord (['H', 'e', 'l', 'l', 'o', '\n', '\r'], Ord)
Ords := [72, 101, 108, 108, 111, 10, 13]
Ord := [72, 101, 108, 108, 111, 10, 13]
open_serial ('COM1', SerialHandle)
* Set the parameters of the serial interface (e.g., a character-based terminal).
set_serial_param (SerialHandle, 9600, 8, 'none', 'none', 1, 2000, 100)
* Display a nice message on the terminal.
write_serial (SerialHandle, ords(['Hello world!', '\n\r']))
* Now read 10 characters from the terminal...
read_serial (SerialHandle, 100, Data)
* ...and if the user typed some characters within the one second...
if (|Data| > 0)
* ...convert the read data to a string.
Read := chrt(Data)
endif
* Finally, close the serial interface so other programs can use it.
close_serial (SerialHandle)