First, you should use Hercules
] utility to check that the communication is OK.
If you can't comminucate with Hercules, then you probably have a problem with your device. Otherwise the problem comes from your code:
- Check that all the parameters are correct in your
- Check the return value from
and if it returns
to have extra information.
One last thing. How you open your port is strange to me. The safest way to open a COM port is:
int comNumber = 3;
sprintf(comName, "\\\\.\\COM%d", comNumber);
comport = CreateFile(comName, ...);
If you don't use
you may have problems for COM ports greater than COM9.
By the way, you should wait a little bit after the port is opened, just to give time for the data to arrive.
For example do a
(wait 2 seconds) before calling