Communication with serial port
-
Hi friends, troubling you yet again... I want to communicate with serial port (COM1). I want to send/receive some data through it. I have read earlier post, & also found a project on serial port. But i m not able to understand anything of that. :sigh: I simply want to brief steps about:suss: ->opening a port ->reading a port ->write a port Thanking you in advance :)
-
Hi friends, troubling you yet again... I want to communicate with serial port (COM1). I want to send/receive some data through it. I have read earlier post, & also found a project on serial port. But i m not able to understand anything of that. :sigh: I simply want to brief steps about:suss: ->opening a port ->reading a port ->write a port Thanking you in advance :)
tina- wrote:
->opening a port
CreateFile
or (CreateFileEx
) function, if you have a look at MSDN configuration sample [^], you can easily figure out the usage.tina- wrote:
->reading a port ->write a port
ReadFile
andWriteFile
: the usage in not-overlapped mode is not such difficult, but perhaps you need to go multithreading. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
tina- wrote:
->opening a port
CreateFile
or (CreateFileEx
) function, if you have a look at MSDN configuration sample [^], you can easily figure out the usage.tina- wrote:
->reading a port ->write a port
ReadFile
andWriteFile
: the usage in not-overlapped mode is not such difficult, but perhaps you need to go multithreading. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]CPallini wrote:
CreateFile or (CreateFileEx)
thanx friend. the project i downloaded (abt serial comm) used CreateFile, but wat do u think will be the first parameter (lpFileName)? :confused: will it be COM1
-
CPallini wrote:
CreateFile or (CreateFileEx)
thanx friend. the project i downloaded (abt serial comm) used CreateFile, but wat do u think will be the first parameter (lpFileName)? :confused: will it be COM1
It must be _T("COM1") for serial port 1. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
It must be _T("COM1") for serial port 1. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]How can we know if a data has been received at the serial port ? is it required to check the port continuously, using ReadFile(), & if it return anything than 0, then we conclude that a data is received ?
-
How can we know if a data has been received at the serial port ? is it required to check the port continuously, using ReadFile(), & if it return anything than 0, then we conclude that a data is received ?
Yes, if you use not-overlapped I/O. This way the application probably needs an additional thread always waiting for incoming data on the serial line. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
How can we know if a data has been received at the serial port ? is it required to check the port continuously, using ReadFile(), & if it return anything than 0, then we conclude that a data is received ?
It depends of the timeouts you specified on the comm port. Basically, you can configure your COM port so that it never waits for data (ReadFile returns immediately) or that it blocks forever until some characters have been received, or something in the middle. Check the SetCommTimeouts[^] function. Anyway working with the serial port is not something easy for a beginner. So expect some frustration because nothing works as expected. But we're to help if needed ;) .
Cédric Moonen Software developer
Charting control [v1.2]modified on Monday, January 21, 2008 2:37:11 AM
-
Hi friends, troubling you yet again... I want to communicate with serial port (COM1). I want to send/receive some data through it. I have read earlier post, & also found a project on serial port. But i m not able to understand anything of that. :sigh: I simply want to brief steps about:suss: ->opening a port ->reading a port ->write a port Thanking you in advance :)
-
Hi friends, troubling you yet again... I want to communicate with serial port (COM1). I want to send/receive some data through it. I have read earlier post, & also found a project on serial port. But i m not able to understand anything of that. :sigh: I simply want to brief steps about:suss: ->opening a port ->reading a port ->write a port Thanking you in advance :)