Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

C++ talking to PIC16F877A via serial

Status
Not open for further replies.

mrvanx

New Member
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
 
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.
 
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...
 
Are you stuck to C++? I've used a free compiler called LCC-Win32 which allows windows program, it's ANSI C though.
 
Sceadwian said:
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!
 
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:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top