Hi, I have a class I usually use for serial communication on Windows/Linux.=20 I can send it of list to you if you want it. Regards /Ake Ale[x] Garbino wrote: > I'm done with all the PIC side of code, which I tought would be the=20 > 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=20 > 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=20 > appropriate bitwise manipulation, gets the relevant information I=20 > need. I also wanted to write a simulator that writes=20 > properly-formatted bytes to the other serial port, so with the use of=20 > 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=20 > using gcc to compile. > > I've been looking all over the place, and nowhere does it seem anyone=20 > has a decent way to interact with the serial port. > There is the > http://www.linuxdocs.org/HOWTOs/Serial-Programming-HOWTO/ > which has about a page of complicated code to do something that should=20 > be simple (after all, the setserial command/serial kernel driver=20 > 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_thre= ad/thread/adb3fc9386015236/fbacf9c056983538?q=3Dserial&_done=3D%2Fgroup%2= Fcomp.lang.c%2B%2B.moderated%2Fsearch%3Fq%3Dserial%26start%3D10%26&_doneT= itle=3DBack+to+Search&&d#fbacf9c056983538=20 > > 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 > #include /* needed for ioperm() */ > #include /* for outb() and inb(), from another site */ > // #include /* 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; > } > > --=20 --- Ake Hedman (YAP - Yet Another Programmer) eurosource, Brattbergav=E4gen 17, 820 50 LOS, Sweden Phone: (46) 657 413430 Cellular: (46) 73 84 84 102 Company home: http://www.eurosource.se =20 Kryddor/Te/Kaffe: http://www.brattberg.com Personal homepage: http://www.eurosource.se/akhe Automated home: http://www.vscp.org --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist