473,783 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comm. between Python and PHP

Hello

I'm building a daemon in Python. It will measure and control some
physical devices on a serial bus. Since it is a daemon, it will never
terminate and I can't interfere with the regulation of the devices by
using command line parameters. I want to control the regulation by
using a Internet browser.

What is the easiest way to make my threaded Python daemon communicate
with a PHP-script running from Apache2 on localhost?

Thank you so far!

Nils Emil P. Larsen
--
My reply-address is valid. www.bios-flash.dk
Min svar-adresse er gyldig. Redning af døde BIOS'er
Jul 18 '05 #1
6 1840
Nils Emil P. Larsen wrote:
I'm building a daemon in Python. It will measure and control some
physical devices on a serial bus. Since it is a daemon, it will never
terminate and I can't interfere with the regulation of the devices by
using command line parameters. I want to control the regulation by
using a Internet browser.

What is the easiest way to make my threaded Python daemon communicate
with a PHP-script running from Apache2 on localhost?


"Easiest" of course depends on lots of things, and mostly on
specifics that you haven't told us, and your personal preference.

Two obvious possibilities that come to mind are "write a file
somewhere from PHP and poll for updates from Python", and
"use sockets (TCP)" or "use UDP".

Maybe if you can describe more about what you need (e.g. what
form will this "control" take?) some even simpler suggestions
will come to mind.

-Peter
Jul 18 '05 #2
It wasn't quite clear, but I assume that you want a PHP script that
can call on the Python daemon and not have the daemon make
calls to a PHP script.

You could use xml-rpc which is built into Python as of version 2.2:
http://docs.python.org/lib/module-xmlrpclib.html
On the PHP side xmlrpc is still experimental. You have to
enable this when you build PHP:
http://us3.php.net/manual/en/ref.xmlrpc.php

You could also just add a simple HTTP interface to your daemon.
It's pretty easy to add an HTTP interface to your daemon.
Look at SimpleHTTPServe r the docs:
http://docs.python.org/lib/module-SimpleHTTPServer.html
You will also need to read the source for SimpleHTTPServe r.py to
figure out how it works (I don't know why they don't just put the
example
in the docs instead of putting the example in the source).

Yours,
Noah

Jul 18 '05 #3
Peter Hansen <pe***@engcorp. com> wrote:
Nils Emil P. Larsen wrote:
What is the easiest way to make my threaded Python daemon communicate
with a PHP-script running from Apache2 on localhost?


"Easiest" of course depends on lots of things, and mostly on
specifics that you haven't told us, and your personal preference.

Two obvious possibilities that come to mind are "write a file
somewhere from PHP and poll for updates from Python", and
"use sockets (TCP)" or "use UDP".


If the data you want to pass is structured then you might consider
XML-RPC which is a cross platform way of passing structured data
around. XML-RPC is part of the python standard library
(SimpleXMLRPCSe rver and xmlrpclib) and there seem to be several
implementations for PHP

http://www.google.co.uk/search?q=xml+rpc+php

That might be overkill for what you want though!
--
Nick Craig-Wood <ni**@craig-wood.com> -- http://www.craig-wood.com/nick
Jul 18 '05 #4
Nils Emil P. Larsen <ne********@pos t.cybercity.dk> wrote:

Hello

I'm building a daemon in Python. It will measure and control some
physical devices on a serial bus. Since it is a daemon, it will never
terminate and I can't interfere with the regulation of the devices by
using command line parameters. I want to control the regulation by
using a Internet browser.

What is the easiest way to make my threaded Python daemon communicate
with a PHP-script running from Apache2 on localhost?


Python is perfectly capable of generating HTML. You don't have to demean
yourself by working in PHP.

Sockets and pipe files are common methods of communicating with a daemon.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #5
Hello
Python is perfectly capable of generating HTML. You don't have to demean
yourself by working in PHP.


Thanks for the tip about using Python instead of PHP to generate web
pages. I may follow it.

Nils Emil
--
My reply-address is valid. www.bios-flash.dk
Min svar-adresse er gyldig. Redning af døde BIOS'er
Jul 18 '05 #6
Hello

Sorry for not being too exact in my request!
If the data you want to pass is structured then you might consider
XML-RPC which is a cross platform way of passing structured data


XML-RPC looks like something very suitable for my needs. It seems
Python handles the remote procedure calls very easily (almost like
local functions).
It also works quite well in PHP. I didn't recompile anything but
downloaded Keith Devens XML-RPC Library (500 lines code). With this I
can call RPC-functions almost as easily as with Python. It took me
just about an hour to get it working...

Thanks everybody!

Nils Emil P. Larsen
--
My reply-address is valid. www.bios-flash.dk
Min svar-adresse er gyldig. Redning af døde BIOS'er
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2346
by: Will | last post by:
Does Python have comm port support built in or does someone have a tool for sending and receiving data in & out of a PC com port? How about for the Mac ? Thanks - Will
3
3970
by: al | last post by:
Hi, I am creating an application in access 97, so coding in vba. I am at the stage of sending values to my external machine, but am stuck at a point. I need to send each character at an interval of 0.1 seconds. So using the timer_event, i have set the timerinterval to 100.
1
3642
by: sarath1111 | last post by:
hi all, I am using comm port for serial communication between 2 PC's using C language. Once I have initialized the COMM port, Is there any option of closing the port in C language. Thanks in Advance, Sarath.B
0
1856
by: David M | last post by:
I am attempting to access the text to speech SDK via. C#. I setup a reference to the "Microsoft Voice Text" Control (vtext.dll) and I added the following code: HTTSLib.TextToSpeechClass v = new HTTSLib.TextToSpeechClass(); v.Speak("THIS IS A TEST"); The code compiled and ran but I do not hear any speech! I did the same code in VB6, and it worked.:
7
2770
by: Michael Chong | last post by:
I wrote a program that communicate with SerialComm. In every 300 milliseconds, my program continuously send & receive data via the serial port once the program starts. My program is once in a while, the serial port seems corrupted because when my data is sent, it doesn't go through the serial port, so as same to receive process. In order to fix this, I have to close the port and reopen the port again. Why?!! Is there any way to fix...
3
4262
by: David | last post by:
I am trying to use the vb 6 comm control in a vb.net project. I am sending ok, but for some reason can not receive anything. I tried using the oncomm event which never is fired. I also just tried to use the input method which always returns Nothing. Does the vb 6 comm control work in vb.net?
4
2636
by: Iceman.Aragorn | last post by:
I'm having an odd problem where im reading input from a comm port (the maker of the software that exports the data TO the comm port is unhelpful). What im reading is fixed length (13 character) sets of data seperated by CR/linefeed. At first, it simply seemed like i was getting messed up data, due to encoding it wrong, or using the wrong font, or something like that, but it turns out, when i analyze the byte stream, that the data i get...
2
9210
by: Max Healey | last post by:
I have written a number of applications that control various bits of hardware via serial data. using VB6 and the comm. control now some one has asked me to do one for a specific piece of equipment, the protocol calls for 9600 8 N 1 all cool there, Then it specifies the following Baud Rate 9600 Startbit Low
2
1912
by: Hank | last post by:
Hello, I would like to get some opinions on using the Comm Port with Access 2000. We have a few jobs coming in that require us to interface with a PLC via the Comm Port. My partner feels we should use a Visual Basic Front End and the VB component as opposed to Access. Has anyone had good luck interfacing to a Comm Port using Access?
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.