From owner-freebsd-questions@FreeBSD.ORG Tue Apr 7 11:30:34 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C3BE106564A for ; Tue, 7 Apr 2009 11:30:34 +0000 (UTC) (envelope-from jalmberg@identry.com) Received: from mx1.identry.com (on.identry.com [66.111.0.194]) by mx1.freebsd.org (Postfix) with ESMTP id E47698FC08 for ; Tue, 7 Apr 2009 11:30:33 +0000 (UTC) (envelope-from jalmberg@identry.com) Received: (qmail 49795 invoked by uid 89); 7 Apr 2009 11:31:10 -0000 Received: from unknown (HELO ?192.168.1.110?) (jalmberg@75.127.142.66) by mx1.identry.com with ESMTPA; 7 Apr 2009 11:31:10 -0000 In-Reply-To: <139b44430904070241j5227d178jd75f6a93057a150a@mail.gmail.com> References: <139b44430904070241j5227d178jd75f6a93057a150a@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v753.1) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <45769C11-D692-4A3B-B979-27A74D9FF094@identry.com> Content-Transfer-Encoding: 7bit From: John Almberg Date: Tue, 7 Apr 2009 07:30:29 -0400 To: Valentin Bud X-Mailer: Apple Mail (2.753.1) Cc: freebsd-questions Subject: Re: C programming question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2009 11:30:34 -0000 On Apr 7, 2009, at 5:41 AM, 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 :). More complicated than you need. The last time I twiddled bits on a serial port, the choice was Assembler, or C, but today my choice would be Ruby. You can probably do whatever you want with a few lines of Ruby, rather than many lines of C. And since you don't know either language, you might as easily learn Ruby as C. Unless you are going to start writing low level code, a high level language like Ruby will let you write any program you need. I haven't needed to write a line of C code in probably 20 years. Check out the Ruby serial port library: http://ruby-serialport.rubyforge.org/ The standard Ruby book is "Programming Ruby" (http:// www.pragprog.com). If you don't know programming at all, they have a "Learn to Program" book that uses Ruby as a first language. -- John