This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to write to COM port with Cx51

Does anyone know how I can write to the COM port on the 8051? I know how to do so in Visual C++ but I'm not sure if its the same way. In Visual C++, I would use the following code:

HANDLE hSerial;
BOOL w_ret;
DWORD write = 19;
char buf[20] = {0};

hSerial = CreateFile("COM1",GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);

COMMTIMEOUTS cto = {MAXDWORD, 0, 0, 0, 0 };

w_ret = WriteFile(hSerial,buf,write,&write,NULL);

Thanks!