^rooker
Posts: 4
Joined: Tue Dec 26, 2017 3:59 pm

FTDI adapter & PHP: CLI works, but not in Apache

Wed Oct 09, 2019 10:08 am

Hello!

Disclaimer: I'm not yet sure if this is an RPi issue, or because of different Debian/PHP versions.
If this is not the right place to ask this, please let me know :)

I've got 2 FTDI USB-to-serial adapters connected to a Raspberry Pi 3.
I'm running PHP code to communicate with a video analog-to-digital converter (ADC).

Now I've moved the FTDI adapters from a PC (Debian 6) to the RPi (Raspbian 10).

Serial communication works fine if I run the PHP code on the commandline (CLI), but throws I/O errors when opening the identical (!) code as PHP (over Apache2) in the browser.
The errors appear randomly for any command that tries to talk to the FTDI adapter...
I've already diffed the 2 php.ini files, and changed them to match: no change at all.
The code is stable and was in daily use since 2012 without any problems.


Has anyone gotten any ideas?
Thank you very much in advance!

Andyroo

Re: FTDI adapter & PHP: CLI works, but not in Apache

Wed Oct 09, 2019 2:36 pm

Possibly because the code is running under user www-data and not Pi?

Check how and who the code ran under and any changes to group membership made on the original box.

Andyroo

Re: FTDI adapter & PHP: CLI works, but not in Apache

Wed Oct 09, 2019 9:56 pm

Possibly the dialout group needs to be added to www-data

Just dawned on me, the groups may be different on the old box :o :roll:

^rooker
Posts: 4
Joined: Tue Dec 26, 2017 3:59 pm

Re: FTDI adapter & PHP: CLI works, but not in Apache

Fri Oct 11, 2019 9:17 am

Thanks for your replies!
I've already checked both: Running as www-data (=apache's user) and the groups, but I'll check again.

I'd assume a more persistent error behavior if it was a permission issue.
It "feels" like the code in Apache isn't waiting long enough to properly finish the call to the serial device, therefore prematurely exiting and then complaining it looks like an I/O error. But that's just a gut feeling. I can't find any timeout value to configure or test this.


Still grateful for any ideas! :)
Thank you very much in advance.

^rooker
Posts: 4
Joined: Tue Dec 26, 2017 3:59 pm

Re: FTDI adapter & PHP: CLI works, but not in Apache

Mon Oct 14, 2019 1:04 pm

To check if it's a version update issue, or maybe related to different CPU architecture, I've now reproduced the same setup on a regular PC (same versions, but non-ARM architecture): Everything works!

Could it be that the *just the Apache* PHP module that is used to talk to the FTDI device has "ARM issues"?
(Not blaming, just pondering how to narrow down the reason for this odd behavior...)

Return to “Other programming languages”