From: Kev on 9 Apr 2010 17:49 I am trying to do a serial interface on a medical pump via Matlab using examples of serial communication that I have found on the internet, but what seems like a really simple task just isn't working for me. Here are the codes that I've been trying with: !mode com1:9600,n,8,1 s = serial('COM1'); fopen(s); fprintf(s,'*IDN?'); get(s,{'InputBufferSize','BytesAvailable'}); This should return me with some device information but on the command window, it only shows: Serial Port Object : Serial-PORT Communication Settings Port: PORT BaudRate: 9600 Terminator: 'LF' Communication State Status: closed RecordStatus: off Read/Write State TransferStatus: idle BytesAvailable: 0 ValuesReceived: 0 ValuesSent: 0 so here it is telling me that the communication is closed, yet in the code that I used, this status should be open shouldn't it? If anyone can point me in the right direction it'll be much appreciated. Thanks in advance
From: Kev on 11 Apr 2010 21:26 anyone?
From: Walter Roberson on 12 Apr 2010 17:36 Kev wrote: > I am trying to do a serial interface on a medical pump via Matlab using examples of serial communication that I have found on the internet, but what seems like a really simple task just isn't working for me. Here are the codes that I've been trying with: > > !mode com1:9600,n,8,1 > s = serial('COM1'); > > fopen(s); > fprintf(s,'*IDN?'); > get(s,{'InputBufferSize','BytesAvailable'}); > > > This should return me with some device information but on the command window, it only shows: > > > Serial Port Object : Serial-PORT > > Communication Settings > Port: PORT > BaudRate: 9600 > Terminator: 'LF' > > Communication State > Status: closed [fid, status] = fopen(s); disp(status); By the way, you should cross-check that terminator 'LF' (linefeed) is correct for the equipment. 'CR' is pretty common, and CR followed by LF is the standard for a bunch of communications systems. The terminator choice would not affect the ability to open the port, though.
|
Pages: 1 Prev: MathWorks::System::SimpleException Next: PS and EPS figures are pixelated |