serial port in C

T

the consiglieri

hello everybody
can u ppl plz help me how to access and send
data to serial port in C....and how to set parameters like baudrate
etc....i want to send data to 8051 ucontroller through it ......thanx
 
I

Ian Collins

the said:
hello everybody
can u ppl plz help me how to access and send
data to serial port in C....and how to set parameters like baudrate
etc....i want to send data to 8051 ucontroller through it ......thanx

Serial ports are very system specific, you'll have to ask on a platform
specific group, or somewhere where ppl can be found.
 
S

Sjouke Burry

the said:
hello everybody
can u ppl plz help me how to access and send
data to serial port in C....and how to set parameters like baudrate
etc....i want to send data to 8051 ucontroller through it ......thanx
I would have a nice sulution, but because of the way you see fit to
ask in babytalk, NO!!
 
T

the consiglieri

Serial ports are very system specific, you'll have to ask on a platform
specific group, or somewhere where ppl can be found.

I am using windows xp professional.....can u help me or suggest some
book or site where i can get some material on it
 
J

Joachim Schmitz

the said:
i dont understand wat u r saying.....

He refers to your SMS style writing, which is frowned upnm here. That last
sententence most probaly should have read:
"I don't understand what you are saying"

Bye, Jojo
 
K

Kojak

Le Sat, 28 Feb 2009 02:25:57 -0800 (PST),
the consiglieri a écrit :
i dont understand wat u r saying.....

Lot of people dislike the 'u', 'r'', 'ppl', 'plz', and so on,
but prefers 'you', 'are', 'people', 'please', ...

Usenet is not sms, you have time to write, so please try to do
little effort against those who answer. they'll appreciate. This
also shows that you respect your interlocutors.

And 'i' as far as I know, should be uppercase.

That's said, I'm not English native speaker, thus I could be wrong.

That was my 2 cents.

Yours,
 
J

jacob navia

the said:
I am using windows xp professional.....can u help me or suggest some
book or site where i can get some material on it

You use the same primitives that you use for files to open a
communications port. Here is the code to open COM1 for instance:
HANDLE hComm;
char *gszPort = “COM1”;
hComm = CreateFile( gszPort,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0);
You use that handle to call ReadFile and WriteFile APIs. Communications
events are handled by SetCommMask, that defines the events that you want
to be informed about (break, clear-to-send, ring, rxchar, and others).
You can change the baud rate managing the device control block
(SetCommState), etc. As with network interfaces, serial line programming
is a black art.Here is an example that is distributed with the Microsoft
SDK:
#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
DCB dcb;
HANDLE hCom;
BOOL fSuccess;
char *pcCommPort = "COM1";

hCom = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // must be opened with exclusive-access
NULL, // no security attributes
OPEN_EXISTING, // must use OPEN_EXISTING
0, // not overlapped I/O
NULL // hTemplate must be NULL for comm devices
);

if (hCom == INVALID_HANDLE_VALUE)
{
// Handle the error.
printf ("CreateFile failed with error %d.\n", GetLastError());
return (1);
}

// Build on the current configuration, and skip setting the size
// of the input and output buffers with SetupComm.

fSuccess = GetCommState(hCom, &dcb);

if (!fSuccess)
{
// Handle the error.
printf ("GetCommState failed with error %d.\n", GetLastError());
return (2);
}

// Fill in DCB: 57,600 bps, 8 data bits, no parity, and 1 stop bit.

dcb.BaudRate = CBR_57600; // set the baud rate
dcb.ByteSize = 8; // data size, xmit, and rcv
dcb.Parity = NOPARITY; // no parity bit
dcb.StopBits = ONESTOPBIT; // one stop bit

fSuccess = SetCommState(hCom, &dcb);

if (!fSuccess)
{
// Handle the error.
printf ("SetCommState failed with error %d.\n", GetLastError());
return (3);
}

printf ("Serial port %s successfully reconfigured.\n", pcCommPort);
return (0);
}
 
J

James Kuyper

the said:
i dont understand wat u r saying.....

We don't understand what you're saying: 'u', 'ppl', 'plz', 'r', 'i'
There are no such words in English.
 
A

Antoninus Twink

We don't understand what you're saying: 'u', 'ppl', 'plz', 'r', 'i'

Is that the Royal We, James?

Either way, it's simply a lie. Say "I'd prefer it if you didn't use
those abbreviations" if that's what you mean, but to pretend you don't
understand them is a lie.
 
K

Keith Thompson

Joachim Schmitz said:
He refers to your SMS style writing, which is frowned upnm here. That
last sententence most probaly should have read:
"I don't understand what you are saying"

And this is why, when someone posts using that style, we should simply
explain that it's not acceptable here rather than ridiculing it or
pretending not to understand it.
 
A

Antoninus Twink

And this is why, when someone posts using that style, we should simply
explain that it's not acceptable here rather than ridiculing it or
pretending not to understand it.

Remind me again who appointed you arbiter of what's "acceptable" here
Keith?

The strongest statement you can make is that you personally don't like
that style. Go ahead if you feel the need to moan in that way - pretty
soon you'll find you've turned into CBF.
 
C

CBFalconer

the said:
I am using windows xp professional.....can u help me or suggest
some book or site where i can get some material on it

Look for a group with microsoft or windows in the name. When you
do try using real English. Silly abbreviations such as u, ppl, plz
and failure to uppercase the first letter in sentences, and use of
multiple periods to end sentences, are highly annoying and make
your posts unintelligible to many.
 
J

Joachim Schmitz

Keith said:
And this is why, when someone posts using that style, we should simply
explain that it's not acceptable here rather than ridiculing it or
pretending not to understand it.

100% agree. And to make it crystal clear: it wasn't me ridiculing the OP...

Bye, Jojo
 
R

Richard

Antoninus Twink said:
Remind me again who appointed you arbiter of what's "acceptable" here
Keith?

The strongest statement you can make is that you personally don't like
that style. Go ahead if you feel the need to moan in that way - pretty
soon you'll find you've turned into CBF.

In many ways he is worse than CBF. The reason being that he can be
informative and helpful when not being an anal retentive. CBF has not
once, that I have seen, provided anthing to this group other than a
cringe at his unbearable self regard and total incompetence and
inability to learn from his mistakes. Keith lets himself down badly with
his constant nannying and desire to be the groups patriarch.
 
T

the consiglieri

this is for for the idiots who hav been posting comments about how to
write proper english here ....ppl like u who hav enuf time to waste
here rather than learnin somethng and helping others see these
things ....and if u dnt like the english get lost and stop posting ur
comments here..idiots

PS . i am very thankful to jacob navia ,hans and scott for their
help ...keep it up fellows
 
C

CBFalconer

the said:
this is for for the idiots who hav been posting comments about
how to write proper english here ....ppl like u who hav enuf
time to waste here rather than learnin somethng and helping
others see these things ....and if u dnt like the english get
lost and stop posting ur comments here..idiots

Totally incomprehensible. Totally lost in spelling errors.
 
R

Richard Bos

the consiglieri said:
this is for for the idiots who hav been posting comments about how to
write proper english here ....ppl like u who hav enuf time to waste
here rather than learnin somethng and helping others see these
things ....and if u dnt like the english get lost and stop posting ur
comments here..idiots

PS . i am very thankful to jacob navia ,hans and scott for their
help ...keep it up fellows

Hmmm... what company did you work for, again?

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top