I am not a Pelles C expert by any means but I do use the IDE and enjoy writing Windows programs. I also write code for PICs and have successfully communicated between PC and PIC without having to call any special drivers from within my code.
I use the CreateFile function and specify "COMx" as the 'file' to open.
Just in case it is of any use to you, I have attached a code snippet of the section I use to identify which ports are available. (I only test up to 9 because higher numbered ports are a bit fiddly and I do not have very many on my PC).
:
case WM_INITDIALOG:
:
for (int i = 1; i < 10; i++) {
sprintf(myPort, "COM%d", i);
hCom = CreateFile(myPort, GENERIC_READ | GENERIC_WRITE,
0, // exculsive access to this 'file'
NULL, // Security Descriptor - cannot be passed to child
OPEN_EXISTING, // Required for COM ports
FILE_ATTRIBUTE_NORMAL, NULL);
if ((hCom != INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_FILE_NOT_FOUND)){
SendMessage(hPorts, LB_INSERTSTRING, -1, (LPARAM)myPort); // append to listbox
}
CloseHandle(hCom);
}
My Listbox gets filled with the names of all COM ports that are available. I then open up the one I want and use ReadFile and WriteFile to communicate. Of course the driver for the USB-to-TTL converter has to have been loaded outside of my program but this only has to be done once.
I hope this is relevant and of some use.
John.