Reputation: 1
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
Reputation: 80325
Upvotes: 1