Start New Discussion within our Software Development Community

Hi and thanks for reading.I'm trying to acces the master PLC of a CAN network using the windows api.It's become a nuisance since i cant' figure this out at all.I will try to be brief since i don't have the source code at hand.
So i'm initializing a handle for the COM1 port with the CreateFile() function.I'm getting the DCB configuration since there is actually another program interfacing with this network which configures the protocol when started.

unsinged long Event;
unsigned long BytesRead;
void* ReadBuff;

HANDLE hPort=CreateFile("COM1",GENERIC_READ,0,FILE_ATTRIBUTE_NORMAL,OPEN_EXISTING,0,0);
SetCommMask(hPort,EV_RXCHAR|EV_CTS|EV_RLSD);
WaitCommEvent(hPort,&Event,0);// this should return .. it doesn't
ReadFile(hPort,ReadBuff,8,&BytesRead,0);

These should be the main steps from what i figured out by now but i can't make anythig to work.I tried the overlapped method still .. nothing.Please guide me.And thanks for the time.

Try and check if the SetCommMask is return true or false. And use GetLastError to see the error message, that's all I can think of.

This article has been dead for over six months. Start a new discussion instead.