Prev: Numerical matrix with text headers
Next: ICA
From: Clayton Chu on 12 Aug 2010 21:41 Hi all, I'm trying to write some code that detects serial devices attached to the computer. It needs to be cross-platform so it must be robust - can't hardcode /dev/ttyUSB* or COM* into the serial port names for handles. I'm using instrhwinfo('serial') to get a list of available ports, so the assignment: hardware = instrhwinfo('serial'); yields a struct, and hardware.AvailableSerialPorts is a field in this struct (more precisely an nx1 cell array). I noticed that instrhwinfo() returns incorrect information in the following scenario: I plug in all my devices and use instrhwinfo('serial') to get port names - say, /dev/ttyUSB0, /dev/ttyUSB1, and /dev/ttyUSB2. I then unplug /dev/ttyUSB2 and check instrhwinfo('serial') again - but the result of this operation still returns 3 available ports! So it seems that instrhwinfo() fetches the proper data once, and on subsequent calls just returns what it returned the first time. Is this a bug or a feature, and how can I get around it - that is, how can I force instrhwinfo() to actually check for instrumentation attached to the computer after the first time I call it?
From: Walter Roberson on 12 Aug 2010 23:33 Clayton Chu wrote: > I'm trying to write some code that detects serial devices attached to > the computer. It needs to be cross-platform so it must be robust > So it seems that instrhwinfo() fetches the proper data once, and on > subsequent calls just returns what it returned the first time. Is this a > bug or a feature, and how can I get around it - that is, how can I force > instrhwinfo() to actually check for instrumentation attached to the > computer after the first time I call it? You cannot do what you want to do in a robust portable way, especially on systems that allow hot-plugging . You might have better success if you were to _drastically_ limit the platform and software versions the code had to deal with. Like to very particular Linux distributions, not even to Linux in general.
|
Pages: 1 Prev: Numerical matrix with text headers Next: ICA |