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 had a web server running from a Windows 7 computer and recently moved everything to an Ubuntu server. All is set up and running smoothly. I do have one page that actually interfaces with the serial port. The only thing I do with it is to set the DTR pin to "true" which applies +12v to the pin. This activates a relay. It is very basic and simple. After moving everything to Linux, this page will no longer work. I knew this would happen. I know the page had code in it to call out "Com1" which would change to "ttyS0". It also had "set_serDTR(True);" in the code. I can't figure out how to get PHP to control the DTR pin on a Linux serial port. Can anyone point me in the right direction?
Hello all,
I had a web server running from a Windows 7 computer and recently moved everything to an Ubuntu server. All is set up and running smoothly. I do have one page that actually interfaces with the serial port. The only thing I do with it is to set the DTR pin to "true" which applies +12v to the pin. This activates a relay. It is very basic and simple. After moving everything to Linux, this page will no longer work. I knew this would happen. I know the page had code in it to call out "Com1" which would change to "ttyS0". It also had "set_serDTR(True);" in the code. I can't figure out how to get PHP to control the DTR pin on a Linux serial port. Can anyone point me in the right direction?
Not without seeing the code, no. However, it's not just ttyS0...it's /dev/ttyS0. Have you tried that?
You will probably have to adjust the permission level on /dev/ttyS0, as your web server probably does not run as root. To actually control the pins, you might find setSerialSignal useful (from PHP, use 'system()' or whatever PHP provides to launch other programs).
--- rod.
I haven't actually tried the page, because I knew I need to make changes, I just didn't know exactly what I needed to do. I will look into your suggestions.
Just by scanning the embedded strings for usage messages, I think the arguments to setSerialSignal are the states of DTR and RTS, respectively. 1 == ON, 0 = OFF.
As far as I can tell, the rest of your plan looks solid. BTW, I tried building setSerialSignal, and to get a clean build, I had to add
I followed the plan and all is well. Well, almost.
I shut my server down and moved it to it's permanent location. When I restarted it, it no longer worked. After chasing wires for a while, I remembered the permissions on the serial port. I logged into it and did a "sudo chmod 777 /dev/ttyS0" and it was up and running again. Now, how do I make the serial port permissions permanent?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.