NAS Server - PHP Script - Control Networked PC Serial Port

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Parappa
Forum Newbie
Posts: 3
Joined: Mon Nov 01, 2010 6:08 pm

NAS Server - PHP Script - Control Networked PC Serial Port

Post by Parappa »

Hi all,

I am trying to work out how to control a Serial Port on a Windows XP PC (which is on a LAN) with a PHP Script which is on a NAS box with a built in Web Server (on the same LAN).

The idea is to have a web page with radio buttons which, when pressed, will send control data to a device connected on the PC's Serial Port.

For example, to be able to switch a light on and off or to read some basic data like temperature back to the web site.

So far I have managed to get my device to talk to the PC, but I am stuck when it comes to the PHP side of things - especially how to get a PHP Script on the NAS Web Server to talk to the networked PC.

If anyone can help I would be grateful. My level of skill is quite limited at this stage as PHP is quite new to me and I want to learn as I go and understand what is happening.

Thanks all,
djlex1928
Forum Commoner
Posts: 31
Joined: Sun Sep 19, 2010 3:23 pm

Re: NAS Server - PHP Script - Control Networked PC Serial Po

Post by djlex1928 »

I think you're probably stepping outside of PHP's capabilities here. (I could be wrong)

If I were doing the same thing I'd look into talking to the serial port with a desktop based language such as Visual Basic. VB can also connect directly to MySQL databases on a PHP server which you could then use to display info such as temperature on your website.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: NAS Server - PHP Script - Control Networked PC Serial Po

Post by Jonah Bron »

Yeah, you probably need to communicate with the device with another program written in a language with facilities for this type of thing with exec().
Parappa
Forum Newbie
Posts: 3
Joined: Mon Nov 01, 2010 6:08 pm

Re: NAS Server - PHP Script - Control Networked PC Serial Po

Post by Parappa »

djlex1928
Thanks for the reply!

I totally agree. After reading up on PHP I do not think it is suitable or within what it is designed for. Everything I have found points to a desktop app that outputs to a MySql DB that PHP reads from and to.

However, I am really struggling with putting this together as I am overwhelmed with the first step of trying to create an app in VB!

If yo have any pointers on the best way to get an app up and running that can feed in to a mySql DB that would be great!

Jonah Bron
Thanks for the reply!

Helped me confirm that I was asking too much of PHP.

Not sure how to solve this with the level of knowledge I have...
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: NAS Server - PHP Script - Control Networked PC Serial Po

Post by Jonah Bron »

If you are just reading data/sending commands right there on the spot, I would skip the database and just call a (in this case VB) program with shell_exec() or exec() from PHP.
djlex1928
Forum Commoner
Posts: 31
Joined: Sun Sep 19, 2010 3:23 pm

Re: NAS Server - PHP Script - Control Networked PC Serial Po

Post by djlex1928 »

If you've never worked with VB before then jumping straight in communicating with the serial port is going to be a bit of a task. There are some examples out there, I've looked at a few before but never gone in too deep.

I used to run a webcam website with some user controlled lights, quite simple to setup using an interface called X10. I bought several X10 controlled sockets and an X10 serial interface connected to a standalone pc, ebay is probably the best place to look for cheap X10 controls. HomeSeer was the server software I used and it ran it's own web server, you can edit HomeSeer's index page to work with your website allowing users to turn on lights etc. (not sure if there is anything available for temperature at the minute)

You may still want to go down the route of building your own software but I'm afraid it's a bit out of my league, I've never touched serial programming. Just providing an easier option that I have experience with and when I used it, worked very well.
Parappa
Forum Newbie
Posts: 3
Joined: Mon Nov 01, 2010 6:08 pm

Re: NAS Server - PHP Script - Control Networked PC Serial Po

Post by Parappa »

djlex1928

Thanks for the reply.

I have not had any luck getting anything to work in VB and find coding to be beyond me.

I decided to simplify this and go for a box that connects the serial device directly to the LAN, so I will be skipping the PC.

This means the web server would need to read data from an IP:Port address. But I don't know how to write the software on the web server :(

Jonah

Thanks for the reply.

I don't know where to start with VB, or how to use a shell_exec() or exec() in PHP.

I wish I could understand this stuff and be able to write little apps, but I just can' get my head around programming.
Post Reply