superabbe
asked on
Serial port in windows
I want to use the serial port in windows and i can't use the _bios_serialcom cause it's a #ifdef in its header so Borland C++ 5.0 dosen't include it...
Witch function should i use in win program ??
I don't understand you. Rewrite #ifdef directive. Or what is the problem ? :)
Which OS do you need to support? And is it 16-bits or 32-bits?
Serial port is treated as a file in win32. So you can open serial port with CreateFile win32 API function.
HANDLE hPort = ::CreateFile( "COM1",
GENERIC_READ | GENERIC_WRITE,
0, // exclusive access
NULL, // no security attributes
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL // No template
);
Besides I guess there is OWL class TFile so you can use it instead of API
HANDLE hPort = ::CreateFile( "COM1",
GENERIC_READ | GENERIC_WRITE,
0, // exclusive access
NULL, // no security attributes
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL // No template
);
Besides I guess there is OWL class TFile so you can use it instead of API
ASKER
rayofunreal:
if i comment the ifdef statement I'll recive a unresolved external in _bios_serialcom..
thui:
Os is win95 ....
Galkin........
i need some more info from you..
How would i config the port to read chars from it during let's say 10 sec ??
i'm gonna receive about 5-10 chars an send 3 char to my d-box..
it must use 19200 baud 8 databits no parity 1 stopbit...
if i comment the ifdef statement I'll recive a unresolved external in _bios_serialcom..
thui:
Os is win95 ....
Galkin........
i need some more info from you..
How would i config the port to read chars from it during let's say 10 sec ??
i'm gonna receive about 5-10 chars an send 3 char to my d-box..
it must use 19200 baud 8 databits no parity 1 stopbit...
To configer port use
SetCommConfig, SetCommMask, SetCommTimeouts and WaitCommEvent win32 API functions. to read and wrtite to port use ReadFile and WriteFile.
SetCommConfig, SetCommMask, SetCommTimeouts and WaitCommEvent win32 API functions. to read and wrtite to port use ReadFile and WriteFile.
ASKER
Argh
Could you give a small example ???
like to config it to 19200 and receive a char or 2 ??
it's a bit hard to understand how microsoft want it to be done ,i think.
ByTheWay this old dos _bios_serialcom , doesen't it support 19200 ??
Could you give a small example ???
like to config it to 19200 and receive a char or 2 ??
it's a bit hard to understand how microsoft want it to be done ,i think.
ByTheWay this old dos _bios_serialcom , doesen't it support 19200 ??
If your still interested, there is a really crap example in MSDN called Comm (TTY).
ASKER
Since i hvent recived a commet from galkin i have to reopen this question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As i remember the _bios_serilal com does not accept higher speed than 9600 , does this code allow me 19200
if i chage the createfile param ?
And i'm not sure what the rts and dtr is.
BTW a good example , where did you find it ? :)
if i chage the createfile param ?
And i'm not sure what the rts and dtr is.
BTW a good example , where did you find it ? :)
ASKER
As i remember the _bios_serilal com does not accept higher speed than 9600 , does this code allow me 19200
if i chage the createfile param ?
And i'm not sure what the rts and dtr is.
BTW a good example , where did you find it ? :)
if i chage the createfile param ?
And i'm not sure what the rts and dtr is.
BTW a good example , where did you find it ? :)
ASKER
As i remember the _bios_serilal com does not accept higher speed than 9600 , does this code allow me 19200
if i chage the createfile param ?
And i'm not sure what the rts and dtr is.
BTW a good example , where did you find it ? :)
if i chage the createfile param ?
And i'm not sure what the rts and dtr is.
BTW a good example , where did you find it ? :)
Higher speeds should work - havn't tried it though
rts & dtr are handshacking signals for hardwate flow control (actually RTS & CTS)
wrote it myself of the win api help files (sorry its crude - but came of a comms & protocoll object i wrote)
rts & dtr are handshacking signals for hardwate flow control (actually RTS & CTS)
wrote it myself of the win api help files (sorry its crude - but came of a comms & protocoll object i wrote)
ASKER
No more comments...
ASKER
No more comments...