Read Interval Timeouts for Serial Communication
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to communicate with a device via serial port. The device continously sends some binary data packages which are seperated by a certain (i.e. 100ms) duration. Therefore, in order to read these packages sequentially, I have to set timeout property of the serial port. In "C", this can be easly done by setting "commtimeouts.ReadIntervalTimeout" (in windows) or termios.vtime (in posix) to 100ms.
Is there anyway to set the same serial port parameter in matlab? I checked all the properties of serial port object in matlab, but I could not find any property for this purpose. (The timeout property of serial object in matlab is not relevant for this purpose.)
Would it at least be possible to set the serial port parameter via a mex file after I create (and open) it matlab? (in other words, can I somehow pass the handle to the serial port to a mex file so that I can natively set the serial port parameter in "C" using "setcommtimeout" (in windows) or tcsetattr (in posix))
0 Kommentare
Antworten (1)
Vinod
am 12 Aug. 2015
I suspect you are better off by using a BytesAvailableFcn callback to read back the specified number of bytes from the device when there are bytes on the serial port. In the BytesAvailableFcn, use Fread to read back the data in the packet.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Instrument Control Toolbox Supported Hardware finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!