串口通信,一般是指RS232、RS422之间的通信。matlab中有专门的serial函数来创建串口对象。设串口ID号为COM1,则创建方法为:>>scom = serial('com1');复制代码创建完串口对象后,一般需要设置串口对象的属性,否则,串口不会相互通信。>> get(scom) ByteOrder = littleEndian BytesAvailable = 0 BytesAvailableFcn = BytesAvailableFcnCount = 48 BytesAvailableFcnMode = terminator BytesToOutput = 0 ErrorFcn = InputBufferSize = 512 Name = Serial-COM1 ObjectVisibility = on OutputBufferSize = 512 OutputEmptyFcn = RecordDetail = compact RecordMode = overwrite RecordName = record.txt RecordStatus = off Status = closed Tag = Timeout = 10 TimerFcn = TimerPeriod = 1 TransferStatus = idle Type = serial UserData = [] ValuesReceived = 0 ValuesSent = 0 SERIAL specific PRoperties: BaudRate = 9600 BreakInterruptFcn = DataBits = 8 DataTerminalReady = on FlowControl = none Parity = none PinStatus = [1x1 struct] PinStatusFcn = Port = COM1 ReadAsyncMode = continuous RequestToSend = off StopBits = 1 Terminator = LF复制代码 |
新闻热点
疑难解答