C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-20-2008, 07:39 AM   #1
Registered User
 
Join Date: Jan 2008
Posts: 19
Sending 1 bit to serial port

Hello,
Anybody know if there is a very simple way of sending 1 bit to like a serial port? I have been reading a few things that seem like they do it but I am not for sure.
blackcell is offline   Reply With Quote
Old 03-20-2008, 07:48 AM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
That obviously depends on the serial port. The "standard" Asynchronous device, e.g. the 8250/16550 type devices in a PC [or any other UART device that I personally know of] are only able to send "lumps" of bits, e.g. 5, 6, 7, 8 bits [plus a start/stop bit at either end of the "lump"].

What are you ACTUALLY trying to achieve, bigger picture like?

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 03-20-2008, 08:16 PM   #3
Registered User
 
Join Date: Mar 2008
Posts: 14
reply

What are you using Unix/Linux or Windows?

In linux just open the serial port /dev/ttyS? or something like that and write() to it

sth like

Code:
  
int serial_handle;

serial_handle = open("/dev/ttyS0", O_RDWR);
Note /dev/ttyS0 in linux is where your serial port is located
O_RDWR is the flags that opens it for read and write.
and then write() to it

but like matsp said

Quote:
are only able to send "lumps" of bits, e.g. 5, 6, 7, 8 bits [plus a start/stop bit at either end of the "lump"].
Hope it helps
scioner is offline   Reply With Quote
Old 05-23-2008, 02:11 PM   #4
Registered User
 
Join Date: Jan 2008
Posts: 19
Sorry, lumps of bits will work. What I want to do is replace an ancient buzzer system. I think I will be using windows server 2003 by the way. Basically I want to set schedules and on the schedules execute my code to send traffic down a serial port which will trigger something on the other end when traffic is detected. Oh, and another thing is I didn't know if it could be that easy. I am no expert when it comes to devices like serial but I think there is an onboard rom chip that does some processing and channeling when receiving data down the serial pipe? Or am I wrong.

Thanks again guys ( and girls? )
blackcell is offline   Reply With Quote
Old 05-23-2008, 03:26 PM   #5
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
For serial port I/O under windows - there are plenty of examples out in the wild. All of them will be using the API's and concepts described in this article: Serial Communications in Win32.

What's the name of the device you're connecting to? What are the connection settings (baud, parity, stop bit, flow control)? Is the serial protocal for the device published online?

gg
Codeplug is offline   Reply With Quote
Old 05-23-2008, 03:28 PM   #6
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
If you just want to trigger something, wouldn't the parallel port of the PC be a better choice. It's got 8 pins that you can set to 0 or 1 individually.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 06-06-2008, 02:30 PM   #7
Registered User
 
Join Date: Jan 2008
Posts: 19
Using serial instead of parallel because of distance capabilities. Also, on the receiving end it seems to be irrelevant. The guy taking care of that says that all he needs to do is have anything flow down the pipe.
blackcell is offline   Reply With Quote
Old 06-06-2008, 11:20 PM   #8
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
So send a single byte of 0xFF.
Or any character for that matter, since all that seems to be required is a sense of "now!", which can be just the arrival of the character.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sending streams over serial port in win32 deian C Programming 2 07-13-2009 12:01 PM
FTP program jakemott Linux Programming 14 10-06-2008 01:58 PM
Serial port programming in Linux g4j31a5 C++ Programming 1 09-28-2006 08:24 PM
Problem with string and serial port collinm C Programming 2 03-23-2005 10:19 AM
Receiving characters on serial port Roaring_Tiger Networking/Device Communication 3 07-01-2004 01:52 PM


All times are GMT -6. The time now is 05:02 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22