Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Apr 2009 09:50:42 +0100
From:      Frank Shute <frank@shute.org.uk>
To:        Valentin Bud <valentin.bud@gmail.com>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: C programming question
Message-ID:  <20090408085042.GA54417@melon.esperance-linux.co.uk>
In-Reply-To: <139b44430904070241j5227d178jd75f6a93057a150a@mail.gmail.com>
References:  <139b44430904070241j5227d178jd75f6a93057a150a@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Apr 07, 2009 at 11:41:54AM +0200, Valentin Bud wrote:
>
> Hello community,
> 
>  I have built with a micro controller a system of power plugs that
>  can be controlled through the serial port.  I have 2 plugs that i
>  can start/stop and check the status of them. This is accomplished
>  by sending different letters (eg. A/W) to start/stop one of the
>  plugs and another set of letter for the other plug and one letter
>  to check the status.
> 
>  Taking into account the fact that my C skills are almost 0 how
>  complicated would be to write a program so I can control that micro
>  controller through the serial port. Or is there some kind of
>  program that can read/write from/to the serial port from the
>  command line. I don't want an interactive program like minicom,
>  just a program that connects and send a command (a letter in my
>  case) to the serial port.
> 
>  Why not minicom (or any other program like it)? My goal is to be
>  able to start/stop the plugs using a web interface.  I have tried
>  using minicom and background it but when i log out minicom closes.
>  If minicom is started i can send commands to ttyd0 with echo, but i
>  can't read anything from serial.
> 
>  Now back to my original question, how hard/complicated will it be
>  to write a C program to control the micro controller through the
>  serial port.
> 
>  Of course on FreeBSD :).
> 

About 10 years ago I adapted a a C program that was used to control a
board (which basically had a chip and a thermocouple on it) via the
serial port.

IIRC, the C was relatively simple but if you're a total beginner then
it would be hard without cribbing code off the 'net.

If you want to learn C then go for it but if you don't you'd be better
off using one of the scripting languages: perl, python, ruby etc. and
your development time will be much reduced.

Also they all have facilities for easily converting your program to
use the CGI so that you can webify the control and I'm sure they all
have some module for using a serial port (comms/p5-Device-SerialPort
in ports for perl).

Have fun!

Regards,

-- 

 Frank 


 Contact info: http://www.shute.org.uk/misc/contact.html 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090408085042.GA54417>