473,395 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

reading com port

Hello
I am connecting a device to one of the com ports.
could some one help in getting some code to communicat with a device and
read its status
I am sure there some code around...

gest regards
wayne
Nov 14 '05 #1
4 1858
wanes98 wrote:

Hello
I am connecting a device to one of the com ports.
could some one help in getting some code to communicat with a device and
read its status
I am sure there some code around...

How you connect to a com port is completely dependent on your platform.
What works for Windows won't work for UNIX. Find a newsgroup dedicated
to your platform.

Brian Rodenborn
Nov 14 '05 #2
wanes98 wrote:
Hello
I am connecting a device to one of the com ports.
could some one help in getting some code to communicat with a device and
read its status
I am sure there some code around...


There is plenty of code around, but it is _all_ tied to specific
platforms and requires system-specific hooks. The system-specific
nature of this problem makes it unsuitable for discussion in a newsgroup
concerned with a platform-independent language like C. comp.lang.c is
such a newsgroup. You need to check newsgroups, mailing lists,
documentation, or technical support for your platform. Google is your
friend: all of www.google.com (for web searches), dir.google.com (for a
web directory), and groups.google.com (for newsgroups) could be useful.
Nov 14 '05 #3
wanes98 wrote:
Hello
I am connecting a device to one of the com ports.
could some one help in getting some code to communicat with a device and
read its status
I am sure there some code around...

gest regards
wayne


Since you insist:
volatile int * const COM_STATUS_REGISTER =
(volatile int * const) 0x40000;
volatile unsigned char * const COM_RECV_REG =
(volatile unsigned char * const) 0x40004;
volatile unsigned char * const COM_XMIT_REG =
(volatile unsigned char * const) 0x40008;

const unsigned int CHAR_RECEIVED = 0x01;
const unsigned int XMIT_BUFFER_EMPTY = 0x02;

unsigned char Read_Com_Port(void)
{
while (*COM_STATUS_REGISTER & CHAR_RECIEVED == 0)
{
;
}
return *COM_RECV_REG;
}

void Send_Com_Port(unsigned char c)
{
while (*COM_STATUS_REGISTER & XMIT_BUFFER_EMPTY == 0)
{
;
}
*COM_XMIT_REG = c;
return;
}
For other variations, see: news:comp.arch.embedded.
For more appropriate help, post to a newsgroup that
deals with your platform or operating system.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #4
In <WV*****************@newssvr31.news.prodigy.com> Thomas Matthews <Th****************************@sbcglobal.net> writes:
wanes98 wrote:
Hello
I am connecting a device to one of the com ports.
could some one help in getting some code to communicat with a device and
read its status
Since you insist:
volatile int * const COM_STATUS_REGISTER =
(volatile int * const) 0x40000;
volatile unsigned char * const COM_RECV_REG =
(volatile unsigned char * const) 0x40004;
volatile unsigned char * const COM_XMIT_REG =
(volatile unsigned char * const) 0x40008;

const unsigned int CHAR_RECEIVED = 0x01;
const unsigned int XMIT_BUFFER_EMPTY = 0x02;

unsigned char Read_Com_Port(void)
{
while (*COM_STATUS_REGISTER & CHAR_RECIEVED == 0)
{
;
}
return *COM_RECV_REG;
}

void Send_Com_Port(unsigned char c)
{
while (*COM_STATUS_REGISTER & XMIT_BUFFER_EMPTY == 0)
{
;
}
*COM_XMIT_REG = c;
return;
}


Please don't post garbage code.
For other variations, see: news:comp.arch.embedded.
What has comp.arch.embedded to do with PC programming?
For more appropriate help, post to a newsgroup that
deals with your platform or operating system.


The only sensible advice in the whole post. The term "com port" strongly
suggests a PC as the hardware platform, but the correct solution is still
heavily OS dependent.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jaywant Dharwadkar | last post by:
We are developing a Web application on J2EE platform and require to support cetain peripheral devices such as MAGTEK PinPad and Card Swipe (http://www.magtek.com/) connected to a PC port. I am...
4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
3
by: JRB | last post by:
I need to read from and write to USB and RS-232 ports in a new project I'm working on. I was thinking about using C#, but I'm not sure if there's a way to do this in that language. If not, any...
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
6
by: Peter | last post by:
I'm interested to know what ideas are out there for reading a parallel port at a constant sample rate while still allowing the user to interact with the GUI. That is, reading it every 10ms for...
4
by: News | last post by:
Hi Everyone, The attached code creates client connections to websphere queue managers and then processes an inquiry against them. The program functions when it gets options from the command...
16
by: bloggsfred00 | last post by:
I need to read incoming bytes on a COM port but I do not want to have the script hang if there is nothing to read. Is there any way to have PHP interrogate a COM port buffer to see if there is...
10
by: lavida | last post by:
Hi All I was looking for how to read barcodes in background from a wifi reader using VB6. my barcode scanner is a wifi reader. When reading, does the incoming data goes to the COM port? even if...
4
by: Shark | last post by:
Hi, I need a help. My application reads data from COM port, this data is then parsed and displyed on: 1. two plotters 2. text box. I'm using Invoke method to update UI when new data is...
9
by: Hal Vaughan | last post by:
I've done a fair amount of Googling for information on reading the serial port in C++ (and in Linux). Unfortunately, out of every 4 hits, 1 seems to be an unanswered question, 1 is someone saying,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.