+ Reply to Thread
Results 1 to 6 of 6

Thread: C++ talking to PIC16F877A via serial

  1. #1
    mrvanx Newbie
    Join Date
    Feb 2007
    Posts
    6

    Question C++ talking to PIC16F877A via serial

    Hey people, this is a robotics question as such but im having a bit of a problem with getting a C++ program, running in cygwin (on windows xp), to chat with a navigation controller (running on a PIC16F877A).

    How can i access and read from/write to the serial port (COM1) inside cygwin?!?! I can use the standard terminal program in windows and it (the PIC) recieves and echos back any characters that i send.

    if this is WAAAAY off topic for the board then i apologise :s


  2. #2
    Kingpin094 Newbie
    Join Date
    Dec 2002
    Location
    Pensacola, FL USA
    Posts
    106

    Default

    Are you refering to writting an application that talks to the serial port that is compiled using gcc?

    A simple goolgle search will yeild windows code to talk to the serial ports.
    I have used serial ports in MFC applications and under linux but not using cygwin under windows.
    Dude, no way!!!!

  3. #3
    mrvanx Newbie
    Join Date
    Feb 2007
    Posts
    6

    Default

    Yer i am compiling using g++ (so yes gcc). I find LOADS of stuff concerning visual C++ and things but i am coding in just straight C++ at the command line, not a windows app etc...

  4. #4
    Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent
    Join Date
    Oct 2006
    Location
    Rochester, NY U.S.
    Posts
    9,826
    Blog Entries
    1

    Default

    Are you stuck to C++? I've used a free compiler called LCC-Win32 which allows windows program, it's ANSI C though.
    "Because I be what I be. I would tell you what you want to know if I
    could, mum, but I be a cat, and no cat anywhere ever gave anyone a
    straight answer, har har."

  5. #5
    mrvanx Newbie
    Join Date
    Feb 2007
    Posts
    6

    Default

    Quote Originally Posted by Sceadwian
    Are you stuck to C++? I've used a free compiler called LCC-Win32 which allows windows program, it's ANSI C though.
    Yer im kinda restricted to using g++ (gcc). The administrator is jammed so far up his own A$$ that he wont even tell me if i can install a USB driver for my camera (a nice 2 minute job!), let alone let us use a different compiler!

  6. #6
    JeffDM Newbie
    Join Date
    Mar 2007
    Location
    Michigan, US
    Posts
    2

    Default

    Given that Cygwin imitates a unix environment, I'd think that UNIX code would do the job. I haven't tried it with Cygwin, but I think you need to execute the standard termios (and maybe ioctl) commands to the "file" in /dev/ that points to your serial port. The commands are confusing but I've managed to get code to work based on sample C code that I've found, I just have not tried it under Windows yet.

    Another possibility is Python. I don't know if Cygwin includes Python, but there is dirt-simple cross-platform code (it's less than 10 lines of code) to make python scripts to perform serial I/O. Then you can possibly call those scripts within C++.
    Last edited by JeffDM; 9th March 2007 at 01:44 PM.

+ Reply to Thread

Similar Threads

  1. PIC16F877A interfacing with Serial Port
    By jasbertfalutine in forum Micro Controllers
    Replies: 10
    Latest: 18th June 2006, 07:26 AM
  2. serial port cud u extend it??????
    By jam_mafia in forum Electronic Projects Design/Ideas/Reviews
    Replies: 5
    Latest: 15th February 2006, 06:52 AM
  3. Serial to Parallel
    By mstechca in forum Electronic Projects Design/Ideas/Reviews
    Replies: 6
    Latest: 30th March 2005, 04:40 AM
  4. pic16f877 serial recieve acting screwy
    By masconejos in forum Micro Controllers
    Replies: 6
    Latest: 9th April 2004, 10:09 AM
  5. Can a Basic Stamp support 2 serial ports?
    By Scruit in forum Electronic Projects Design/Ideas/Reviews
    Replies: 13
    Latest: 15th August 2003, 02:07 PM

Tags for this Thread