LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Program worked one day, but after the weekend and a reboot it broke. (https://www.linuxquestions.org/questions/programming-9/program-worked-one-day-but-after-the-weekend-and-a-reboot-it-broke-4175660594/)

little necro 09-09-2019 07:46 AM

Program worked one day, but after the weekend and a reboot it broke.
 
So I currently have PHP program using PHP serial to send a TAP protocol message to a paging system. The PHP program calls a python program in order to get information from another serial port. This was working on Friday, but then I shutdown the server and went home for the weekend. I came back in today and booted it back up to find my program no longer works. On Friday I remember I started the GUI and got some error about access denied to the port that talks to the paging system.

Does anyone know why my program worked one day but not the other?


Edit:
So I swapped the ports, I had receiver on ttyS0, and pager on ttyUSB0. I swapped these around and edited the program to reflect the swap and everything worked. Anyone know how this solved the problem so don't have to do that swap in the future. It's fine for testing, but not for the final solution.

proN00B 09-09-2019 07:55 AM

Have you done a scan for gremlins?

scan gremlins

NevemTeve 09-09-2019 11:27 AM

Accidental working doesn't prove your program being good. So simply you have a problem to solve.

TB0ne 09-09-2019 11:55 AM

Quote:

Originally Posted by little necro (Post 6034823)
So I currently have PHP program using PHP serial to send a TAP protocol message to a paging system. The PHP program calls a python program in order to get information from another serial port. This was working on Friday, but then I shutdown the server and went home for the weekend. I came back in today and booted it back up to find my program no longer works. On Friday I remember I started the GUI and got some error about access denied to the port that talks to the paging system.

Does anyone know why my program worked one day but not the other?


Edit:
So I swapped the ports, I had receiver on ttyS0, and pager on ttyUSB0. I swapped these around and edited the program to reflect the swap and everything worked. Anyone know how this solved the problem so don't have to do that swap in the future. It's fine for testing, but not for the final solution.

Would help to know what the "some error about access denied" was, since that's probably the root cause. Also be helpful to know what version/distro of Linux, PHP, etc.

little necro 09-09-2019 12:41 PM

Quote:

Originally Posted by TB0ne (Post 6034930)
Would help to know what the "some error about access denied" was, since that's probably the root cause. Also be helpful to know what version/distro of Linux, PHP, etc.

I cannot provide that because I cannot get the error to come back up. I think it is an issue with the configuration on the serial ports. I currently have everything set through the programming.

little necro 09-09-2019 12:43 PM

Quote:

Originally Posted by NevemTeve (Post 6034921)
Accidental working doesn't prove your program being good. So simply you have a problem to solve.

The method to solve the issue was just unplugging the serial port and pluggin it back it, I tested by restarting multiple times to see the result. When I start the server the port will not work with the php program until it has been unplugged and plugged back in.

little necro 09-09-2019 12:58 PM

So if I write a python script that runs at the start and opens the port that is connected to the paging system and then close it everything works as intended. So logically there must be an issue with PHP serials opening of the port for the first time or something that I am missing.


Perhaps I will remove PHP using serial all together then.

TB0ne 09-09-2019 02:59 PM

Quote:

Originally Posted by little necro (Post 6034948)
I cannot provide that because I cannot get the error to come back up. I think it is an issue with the configuration on the serial ports. I currently have everything set through the programming.

Nothing in the PHP logs??? And version/distro of Linux? PHP????
Quote:

Originally Posted by little necro
The method to solve the issue was just unplugging the serial port and pluggin it back it, I tested by restarting multiple times to see the result. When I start the server the port will not work with the php program until it has been unplugged and plugged back in.

Might be permissions on the device itself, or that the Apache user needs to be added to the tty group.
Quote:

Originally Posted by little necro
So if I write a python script that runs at the start and opens the port that is connected to the paging system and then close it everything works as intended. So logically there must be an issue with PHP serials opening of the port for the first time or something that I am missing. Perhaps I will remove PHP using serial all together then.

Your program; your call.

astrogeek 09-09-2019 03:06 PM

@proN00B: Welcome to LQ Programming forum.

Please keep posts in the Programming forum on topic and limit the amount of banter in response to other's questions.

From the LQ Rules:

Quote:

Do not post if you do not have anything constructive to say in the post.
Thanks.

michaelk 09-09-2019 06:16 PM

It might help knowing the distribution / version you are running.

Without knowing anything about the PHP program, serial port php class or your python script it is impossible to say what is wrong.

At face value /dev/ttyS0 would indicate a hardware device and I find it strange that whatever was connected to it one day would change the next.

Quote:

On Friday I remember I started the GUI and got some error about access denied to the port that talks to the paging system.
Sounds like a permission problem. The typical problem with accessed denied to the port is the user that is trying to access the serial port does not belong to the dialout group. Reconnecting the serial port might mean the device is not being recognized at startup. Check the dmesg output and also check the web server logs if running your php script from a web server.

Samsonite2010 09-10-2019 10:03 AM

You do get issues with ports being reserved and reassigned - are devices always guaranteed to be the same number each time? Especially if connections are not closed at the right time.


All times are GMT -5. The time now is 12:13 PM.