ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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...
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.
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
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.
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...
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.
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
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.
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...
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
Quote:
Originally Posted by schmitta
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.
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....
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.