LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-31-2011, 05:42 PM   #1
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Rep: Reputation: Disabled
How do I communicate between a program and LAMP


I am a newbie of course. I have a number of identical devices that contain a pic microcomputer. Each device is connected to a serial bus and that serial bus is connected to a serial comm port on a PC running LINUX. A program runs continually under linux that monitors the serial port and also needs to communicated (both ways) with the http server running lamp (xampp). 1) do I need an RTOS to do this? 2) how do I communicate between the server and the program? I have never installed a server before nor have I communicated between the running server and a running program. Thank you. Alvin.....
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-31-2011, 07:39 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Quote:
how do I communicate between the server and the program
you type it
Quote:
on a PC running LINUX
on a pc running the KERNEL only ???? and no operating system ?
 
0 members found this post helpful.
Old 06-01-2011, 11:34 PM   #3
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
How does the appachie server communicate with the

1)The server and the program are running on the same machine. The CLIENT is the one who types it but how does the server communicate to the program that is running on the same machine -- By a common ram area?
2) The distro is DAMN SMALL LINUX - DSL . The RTOS would of course be running in the pre mentioned program to be able to handle the serial as well as the communications from the server. It turns out that the serial is more like a mainframe than an embedded micro - ie all serial communications is handled like fileio through a semi-intelligent system routine. So I can probably rely on linux to buffer the serial io on input which is what I was worried about and for which I thought I may need an RTOS running in the program to quickly handle any input. It turns out that the serial io will be halfduplex so I have plenty of time to reply. The burning question is " how does the main program handling my application communicate with the server that is running on the same machine", Unfortunately I do not know enough about TCP/IP and server IO both between the client and also between the server and the application running on the same machine. When I am talking about "Server" I mean "appachie" -- the routine.
 
Old 06-02-2011, 04:35 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,724

Rep: Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918
Shall we assume that your goals are to store data in a database and then be able to display it in a web page? In addition I assume the serial program is something you wrote yourself. If so what language?

mysql has several APIs (c,perl, python ruby) where you could write the data directly into a database. Then with apache and php you could display the data in a web page. http://dev.mysql.com/doc/refman/4.1/en/c.html
 
2 members found this post helpful.
Old 06-02-2011, 09:15 AM   #5
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
How the application works.

The main program (in C) would be launched when the system is first brought up. The application would then do a broadcast to the devices on the serial bus link to report in. Each device's information would be recorded in MySQL. After thinking and doing some research I would most likely have the client's html issue PHP commands that would spawn (execute) routines on the server that would need to communicate with my main application on the server. I guess my main question now is how these PHP spawned routines would communicate with main application. I am a newbie and have not written anything in this area as yet. Maybe the communication could be performed by a shell executed routine that would pipe to the application without spawning a new copy of the application. Possibly this could be done by knowing the main application's PID to specify what running routine should be on the other end of the pipe. Any help you could give me would be greatly appreciated. Thank you. Alvin...
 
Old 06-02-2011, 11:50 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,724

Rep: Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918
mysql and apache are separate servers so there really isn't a need for HTML for what you want to accomplish. IMHO it would be better to have your main program write directly to the database.

LAMP is just a bundle of software. In a nutshell, the main selling point is dynamically created web pages with PHP, PERL or Python being the means to getting data from mysql.

Last edited by michaelk; 06-02-2011 at 11:57 AM.
 
1 members found this post helpful.
Old 06-02-2011, 11:57 AM   #7
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
i would have to agree, in your scenario imho you would only need apache/php if you wanted remote display of the data (you wanted a PERSON to log into the database remotely and audit the contents of the database) otherwise, you should simply write the program to execute all the read/write queries on the database and be in full charge of the database, the more intermediate steps, the better chance of something breaking or a breach of security/integrity of the data in question.
 
1 members found this post helpful.
Old 06-02-2011, 12:50 PM   #8
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
The user will be a remote client. The user will have to change values in the devices that are on the serial bus which is connected to the running application on the PC running LINUX. So I have to communicate from the program communicating with the client - which I assume is apache and the application talking to the serial devices. How do I communicate between apache and my application both running on the same PC. Thanks. Alvin...
 
Old 06-02-2011, 02:51 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,724

Rep: Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918
Depends on how you communicate with the application talking to the serial devices. PHP might be the easiest.
Lots of examples on the web, HTML/PHP forms.

Last edited by michaelk; 06-02-2011 at 02:59 PM.
 
1 members found this post helpful.
Old 06-02-2011, 02:55 PM   #10
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
another way would be to read up on how to use c/c++ to make cgi applications which can run on an apache webserver and commenunicate with mysql databases and talk to serial ports

otherwise there is a class for php to communicate with serial ports, i forget where it is off hand, but either way this task can be done in a single programming language.
 
1 members found this post helpful.
Old 06-03-2011, 12:53 PM   #11
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
I am now reading a book that is suppose to educate the reader on apache, php and MySQL in a weekend. I will still need a resident routine to get updates from the serially connected devices in a periodic way. I now know that I can execute shell commands from php so I will need to be able to communicate from the routine spawned by the shell command to the running application. I will probably have to use a pipe to do that but I do not know enough to know how to specify the running application. I imagine the PID will be involved to get the information to the correct running routine. Any thounghts would be greatly appreciated. Thanks. Alvin...
 
Old 06-03-2011, 01:23 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,724

Rep: Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918Reputation: 5918
Just out of curiosity is this a school project?
How fast do you need to poll the PICs?
 
0 members found this post helpful.
Old 06-03-2011, 01:44 PM   #13
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
Quote:
Originally Posted by schmitta View Post
I will still need a resident routine to get updates from the serially connected devices in a periodic way.
Linux has a built in utility for doing exactly that, it's called cron, as long as you are doing some reading, read up on how to set up a cron job to run your script periodically.
 
1 members found this post helpful.
Old 06-03-2011, 05:14 PM   #14
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
I graduated from Virginia Polytechnic Institute and State Universty (Virgina Tech) in 1973 with a BS in Electrical Engineering. I will be 60 years old at the end of this month. No this is not a school project. What it is is a device that I have been working on since 1986 and which I hope to become patent pending on at the end of July. My money runs out at the end of the year and with very little retirement (having been out of the work force for 25 years) this project has to pay for the rest of my life. The project is a mist control system for plant propagation using cuttings. I am working with a guy that has 227 green houses and nine (9) propagation houses which could use 48 of my devices. All 48 devices connect through an RS485 serial network (bus) to the PC running Linux. Depending on how secure I can make it the user will be able to access and modify the mist profile of each unit over the internet. The device I am patenting measures mist using the dielectric constant of water and an electric field. Without going into further detail I am trying to decide on using Linux or eRTOS (an RTOS with TCP/IP built in) under DOS as my control center . The wholesale nursery I am working with sells to smaller retail nurseries. There are many wholesale nurseries in the US and world wide. Alvin....
 
Old 06-24-2011, 01:55 AM   #15
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
I may have found what I have been looking for. It looks like I need to create a daemon to run as a background task that would communicate with the serial network, apachie and MySQL. I have found out how to write the code in the daemon HOWTO. Alvin...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Enterprise LAMP Summit & Big LAMP Camp LXer Syndicated Linux News 0 09-21-2009 01:51 AM
LXer: LAMP vs. LAMP Rematch LXer Syndicated Linux News 0 11-08-2006 03:03 AM
A program for FC4 to communicate with a Windows Hyperterminal Program at other end vhasun Linux - Software 2 05-19-2006 02:54 PM
My C Chat Program is unable to communicate. mcp_achindra Programming 1 03-20-2004 10:04 AM
program to communicate directly with ethernet sabby Programming 4 12-18-2002 11:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration