Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Serial port connection for send and receive

953 views
Skip to first unread message

Michael Ray

unread,
Sep 8, 2009, 4:57:35 PM9/8/09
to
How to connect to a local serial (com) port to send a string and receive
the returned result?
The windows stock "Hyperterminal" communication app allows this, but need
control within PB application.
PB 10.5, Windows XP.
--
Michael


Roland Smith [TeamSybase]

unread,
Sep 9, 2009, 8:23:33 AM9/9/09
to
You can read or write to the com ports as if they were a file. Just use COM1
or whatever the port name is for the filename.

If you need more control than the built-in file functions, I have examples
of the API functions in this example:

http://www.topwizprogramming.com/freecode_ftpedit.html

CreateFile is used to open files and CloseHandle closes the file. ReadFile &
WriteFile are used to read or write. Look in the object n_wininet in
function of_readfile or of_writefile.

The following is from the MSDN docs for CreateFile:

The CreateFile function can create a handle to a communications resource,
such as the serial port COM1. For communications resources, the
dwCreationDisposition parameter must be OPEN_EXISTING, the dwShareMode
parameter must be zero (exclusive access), and the hTemplateFile parameter
must be NULL. Read, write, or read/write access can be specified, and the
handle can be opened for overlapped I/O.


"Michael Ray" <ra...@SoftwareForToday.com> wrote in message
news:4aa6c53f$1@forums-1-dub...

Michael Ray

unread,
Sep 11, 2009, 9:04:08 AM9/11/09
to
Thank you for the replies!

No matter what I did with the File functions FileReadEx always returned an
error.
The ftpedit example declared the same or similar local external functions as
Serial Comms, but it appeared to be much more than what I needed. Thanks
Roland for your current and past support!

The Serial Comms code specifically addressed and solved my serial connection
issue! I only had to learn how to import / recreate the objects from
exported source. After that, it seemed designed just for me. I am curious
how the other (unused) structures might be used. Thank you very much Dave
Hauze!!

--
Michael

"Dave Hauze" <david...@steeldynamics.com> wrote in message
news:4aa7a988$1@forums-1-dub...
> I've attached an NVO that has all you need (along with some structures) to
> communicate with a serial port. The functions are pretty straight forward,
> and I've included a couple of extra helpful structures to use in your
> object that calls the serial comm NVO. Hope this helps.
>
> --
> Dave Hauze

> "Michael Ray" <ra...@SoftwareForToday.com> wrote in message
> news:4aa6c53f$1@forums-1-dub...

hsfu...@gmail.com

unread,
Apr 7, 2014, 6:09:35 AM4/7/14
to
Hi Micheal, Do you still have the sample Serial Comms code? I am running into the same problem as you faced before, would appreciated you can share the code with me.

Thanks
FUN
0 new messages