PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 7th, 2013, 08:09 PM
ConnorGames ConnorGames is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 3 ConnorGames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 51 sec
Reputation Power: 0
PHP5 - Controling a python console from php?

I am trying to write a single user, intranet only PHP control panel for my 3d printer using pronterface's pronsole.py interface - it is just a command line, takes commands from stdin, writes to stdout. I thought to use proc_open, but then if the user closes the page, I would have to terminate the process(not what the user wants) OR leave it running and loose the i/o streams(not desirable because then I cant allow the user to regain control). Sessions are not an option because this site will only allow one job at a time due to hardware limitations, and i would like it to be controllable from any computer. I don't know if PHP likes to read/write file pointers to databases or files, but I assume not. What is the best way to do this? Should i just give up on using pronsole and write my own logic that writes to /dev/ttyUSB0? Thanks for help with this vexing problem!

Reply With Quote
  #2  
Old January 7th, 2013, 09:06 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 29 m 55 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Well it's just a Python script. Does it do anything unusual or cryptic or something that would be a hassle to rewrite in PHP?

And so what if the connection closes. Can't you just reconnect?

Reply With Quote
  #3  
Old January 7th, 2013, 09:14 PM
ConnorGames ConnorGames is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 3 ConnorGames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 51 sec
Reputation Power: 0
I don't think a rewrite in PHP would be that hard, and it might be required because now that I think about it,reconnecting resets the printer. I actually don't know much about linux device files, but I'm assuming it's possible to write to them discontinuously (if thats the right way to say it), so a rewrite in PHP is probably the way to go, especially for expandability. I was just wondering if there was was simple solution.

Reply With Quote
  #4  
Old January 7th, 2013, 10:26 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 29 m 55 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Depends on the device. If you don't need to adjust port information (baud and the like), or in other words don't need an ioctl() on it, then you can work on the device file just like it were a regular file.
Regardless it sounds like you'll need some kind of spooler: sits in the background waiting for stuff to do. You can't serialize file handles which means you can't put it in a database or save it in the session. And without being particularly careful you can't open it in one script and close it in another either.

Reply With Quote
  #5  
Old January 7th, 2013, 11:09 PM
ConnorGames ConnorGames is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 3 ConnorGames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 51 sec
Reputation Power: 0
Thanks!

Quote:
Originally Posted by requinix
Depends on the device. If you don't need to adjust port information (baud and the like), or in other words don't need an ioctl() on it, then you can work on the device file just like it were a regular file.
Regardless it sounds like you'll need some kind of spooler: sits in the background waiting for stuff to do. You can't serialize file handles which means you can't put it in a database or save it in the session. And without being particularly careful you can't open it in one script and close it in another either.


I will probably write a spooler, the thought of just how easy it could be(I could even integrate it into the python script) just crossed by mind and made this seem like a viable option. Thanks a ton!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - Controling a python console from php?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap