Read Interval Timeouts for Serial Communication
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Vinod
le 12 Août 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 commentaires
Voir également
Catégories
En savoir plus sur Instrument Control Toolbox Supported Hardware dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!