?
Solved

Read 8 bit binary data from the Serial Port (RS232)

Posted on 2003-02-23
7
Medium Priority
?
3,611 Views
Last Modified: 2013-11-15
Dear All,

I want to write a code in C to read data packets of 8bit binary, from an RS232 with one start bit, no parity, no stop bits. I also need to store the data in a text file. It would be really helpful if oyu could send me any sample code in C. The program will operate in Windows.

Many thanks,

Michalaros
0
Comment
Question by:michalaros
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:Kocil
ID: 8004021
DOS or Windows or Linux ?
0
 

Expert Comment

by:CHENSHILIH
ID: 8007841
Hi michalaros :
   There are so many possible solution, in DOS/Win95/Win98/WinMe/Win2000/WinXP. For example, you can use Moxa Rs232 Driver. There are two choices, one is use
the rs232 port of PC, and the other is add-on rs232 card.
you can visit the following site :

    http://web2.moxa.com.tw/services/download/download.asp

    It supports : DOS/Windows/Linux Driver, and You need to installed the driver and library, then write your applications.



0
 
LVL 1

Expert Comment

by:sharptek
ID: 8009448
If you're running on DOS/win95/win98 then you can write 'C' code to interface directly with  the rs232 chip registers - which is very flexible and fast. If on the other hand you are running an NT based OS -WinNT,win2000,winXP then you will need to interface with an RS232 driver  less efficient but possibly more stable.. Which is your preferred approach?
I've got some code knocking about somewhere for the former if thats what you need I'll dig it out :)
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
LVL 2

Accepted Solution

by:
honey_hamster earned 150 total points
ID: 8009875
Try the following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_functions.asp

To start, you'll need to look at the following Windows API functions:
CreateFile()   - opens the COM port
GetCommState()
SetCommState() - sets baud rate and other config
WriteFile()    - writes serial data
ReadFile()     - reads serial data

Hope this helps.
0
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 8014434
Currently i do not remember the interrups that are used for that purpose. Then also you can consult the book titled ADVANCED MS-DOS PROGRAMMING. There you will get sample code and all with correct interrupt numbers.

Hope that it may help you
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10014718
Nothing has happened on this question in over 10 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by honey_hamster [grade B] (may lead to a solution).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question