Click here to Skip to main content
15,921,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to communicate with an equipment (SR780 from SRS) using serial port, in Visual basic (VB). I can send (write) but am not able to read. However, I can write and read using hyperterminal without any problem.

Using the same VB code, and the same computer, I am able to communicate with another instrument (QCM200, from the same company) via serial port. Hyperterminal also works fine with this instrument. I am not able to figure out what can go wrong.

I am using Windows 7, 64 bit. Visual Studio community edition 2013. .Net 4.6.

Any help is appreciated.

Best Regards
S. Ramanathan

What I have tried:

I am using readline and am getting a timeout error. Increasing the weight time doesn't help

I tried using readto(vbLf),then replaced vbLF with vbCr, then with vbCrLf and none of them help.
Updated 4-Jun-16 15:57pm
Richard MacCutchan 4-Jun-16 12:03pm    
Most issues with serial ports are due to the nature of the device or its connection. You should check with the manufacturer to see if they provide any SDK/API or documentation for the correct access methods.
Sergey Alexandrovich Kryukov 4-Jun-16 13:58pm    
What kind of help would you expect, without a single line of code shown? And even if you did that, how would we know if all the settings match the device's requirements? Just check up all thoroughly, compare with hyperterminal settings which work...

1 solution

As it is an instrument I presume you want to send a SCPI command and then read the response within a short time.

For SerialPort.ReadLine to work, the response must contain a termination character equal to the one set by the property SerialPort.NewLine (default is Line Feed).
So read the documentation and check what termination character the instrument is using.

Or it could be that the instrument is expecting as specific termination character to process a command.
Same thing, read the communication.
If the instrument accepts the command sent, you can also check by sending a command that is visibly detectable on the instrument, such as turning off the display or something similar.

When dealing with serial port communication, there is a nice tool called PortMon.
PortMon will monitor everything that is happening on the serial port and is very useful in this kind of situations.
It is a free tool and you can download it here: Portmon for Windows[^]

Using PortMon you can compare what data is sent when you are using HyperTerminal (and it works) with your own application (and it doesn't work).
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900