PDA

View Full Version : Pleas help me (about Reading data from COM port)


asterix
October 13th, 2002, 03:55 PM
Hello people! Who can give me advise why i cannot read date from port?

I open the port with CreateFile
after i fill in DCB:

dcb.BaudRate= CBR_9600;
dcb.fDtrControl= DTR_CONTROL_ENABLE;
dcb.BaudRat= CBR_2400;
dcb.fDtrControl= DTR_CONTROL_DISABLE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fRtsControl = RTS_CONTROL_ENABLE;

After this i send some commands with remote control unit
But, when i use function : ReadFile, i get nothing, onli ZERO why???

Mark F
October 13th, 2002, 03:55 PM
It depends on the type of IR receiver you are using. Some require you to raise the RTS and/or DTR lines to give them power. Do this using the EscapeCommFunction() Win32 call. Others require a specific init command be sent before they work.

Did you fill the DCB using the GetCommState() call before changing the values you care about?

Did you set the timeout values for the port using SetCommTimeouts()?

The source code for a bunch of plugins is available on this page (http://www.girder.nl/developer.php). Many use the serial port.

asterix
October 13th, 2002, 03:55 PM
The matter of the fact that i used sources from "Developer" for example :
Girder 3.1 API->UIR. I did the same settings like in this programm:
For example there try write 2 simbols 'I' and 'R': WriteFile
Then this programm try to read simbol 'K':ReadFile
But nothing, it is very strange.
Maybe i try bad way? I have remote control unit, when i run Girder i push buttons of remote control and can look in Girder panel diffrent codes:3001 and so... It's mean that data were wrotten and were red, but how to compatible my programm i dont know

Mark F
October 13th, 2002, 03:55 PM
What receiver are you trying to control?