rancan
6 years agoOccasional Contributor
Serial Port Communication
Hi,
I am trying to create a connection with port com, and I am using JavaScript.
The goal is to send the HEX sequence and read the HEX back from the port.
I copied from this page https://support.smartbear.com/testcomplete/docs/scripting/working-with/com-ports.html and I modified a bit, here's what I have:
function Test() { var Port, s; Port = dotNET.System_IO_Ports.SerialPort.zctor_4("COM6", 9600); Port.Open(); // Writing data to the port Port.Write("1A030688"); // Waiting for response aqUtils.Delay(1000); // Processing response if (Port.BytesToRead != 0) { s = Port.ReadExisting; Log.Message(s); } else Log.Warning("No data"); Port.Close(); }
It gave me "No Data", I believe it's because I was sending HEX instead of Bytes, but I am not sure how to fix it.
When i tried to remove the 'if' clause, it gave me a success, but it's blank.
It's been a few days but I still don't know how to solve it. I would really appreciate it if anyone could help me with this.
Thank you very much.