Brandy
Brandy

Reputation: 1

Send strings to ciacomport

I am trying to write a Delphi application to control a scientific instrument. I have monitored the serial port connected to the instrument and found that the computer establishes communication by sending 18 null characters to the instrument as follows:

00 then 20ms delay
00 00 00 00 00 00 00 00 then 30ms delay
00 then 20ms delay
00 00 00 00 00 00 00 00

The instrument then responds with a series of null characters.

Using the TCiaComPort Delphi component I have written the following code to send the first 18 characters to the instrument.

Serial1.Open := True;

Serial1.SendStr(chr($00));

Sleep(20);

Serial1.SendStr(chr($00) + chr($00) + chr($00) + chr($00) 
    + chr($00) + chr($00) + chr($00) + chr($00));

Sleep(30);

Serial1.SendStr(chr($00));

Sleep(20);

Serial1.SendStr(chr($00) + chr($00) + chr($00) + chr($00) 
          + chr($00) + chr($00) + chr($00) + chr($00));

I then set a breakpoint in the OnDataAvailable event of TCiaComPort to stop the application as soon as the instrument responds but the application does not reach the breakpoint suggesting that the instrument did not respond.

Any suggestion?

Upvotes: 0

Views: 438

Answers (1)

MBo
MBo

Reputation: 80325

  1. Check that port settings are the same (baudrate, flow control etc)
  2. Check in port monitor that your program sends the same byte sequence as dedicated one (without linefeeds etc)
  3. If your device is really sensitive to time intervals, you cannot guarantee that they are accurate.
  4. Is there any setting in ciacomport for event mask (to be ready for RXCHAR)?
  5. It is rather strange that device works with only zero bytes. Are you sure that you see real data exchange? (try PortMon from Russinovich/Microsoft)

Upvotes: 1

Related Questions