> I'm done with all the PIC side of code, which I tought would be the
> hard part to learn. Until I tried reading the serial port!
>
> I assumed a simple:
> ofstream serial ("/dev/ttyS1", ios::out | ios::app);
> if ( !serial.is_open() ) {
> cout << "Can't open serial port" << endl;
> return 0;
> }
> serial << "Hello";
>
> Would do the trick, but although echo & cat works fine from the
> command line, the serial port doesn't react the same.
>
> I'm trying to write a bit of code that reads a byte stream and through
> appropriate bitwise manipulation, gets the relevant information I
> need. I also wanted to write a simulator that writes
> properly-formatted bytes to the other serial port, so with the use of
> a null-modem cable I could make sure my program was working fine.
>
> Does anyone have some simple way to read/write the serial port??
>
> -Alex
>
>
>
> More details:
> I'm running 2.6.x, on a Gentoo linux box, with the latest glibc, and
> using gcc to compile.
>
> I've been looking all over the place, and nowhere does it seem anyone
> has a decent way to interact with the serial port.
> There is the
> www.linuxdocs.org/HOWTOs/Serial-Programming-HOWTO/
> which has about a page of complicated code to do something that should
> be simple (after all, the setserial command/serial kernel driver
> already does all the baud/parity stuff!!).
>
>
http://cpp.snippets.org/browser.php
> Makes a separate class...
>
>
>
http://groups-beta.google.com/group/comp.lang.c++.moderated/browse_thread/thread/adb3fc9386015236/fbacf9c056983538?q=serial&_done=%2Fgroup%2Fcomp.lang.c%2B%2B.moderated%2Fsearch%3Fq%3Dserial%26start%3D10%26&_doneTitle=Back+to+Search&&d#fbacf9c056983538
>
> reads to a stream buffer, but doesn't work when I run it...
>
> There is also this:
>
http://www.erlenstar.demon.co.uk/unix/faq_4.html#SEC49
>
> And I also found something with outb similar to :
>
> #include <stdio.h>
> #include <unistd.h> /* needed for ioperm() */
> #include <sys/io.h> /* for outb() and inb(), from another site */
> // #include <asm/io.h> /* for outb() and inb() */
>
> int main(void)
> {
> if (iopl(3)) {
> printf("Sorry, you were not able to gain access to the ports\n");
> printf("You must be root to run this program\n");
> return 0;
> }
> outb(34324,0x03f8); /* Sends 0011 0010 to the Data Port */
> return 0;
> }
>
>