PHP to serial with weird baud rates

I am trying to use PHP to send text to an LED sign so that I can send support ticket numbers to it. The sign itself is a work; he came from eBay and is poorly prepared with little or no documentation. After working with him for a while, I was able to figure out how it is expected that the material will be sent to him, and that the baud rate is 28800. I already know how to communicate with things like using PHP, but I don’t know how to change data transfer rate for something non-standard. I tried other data rates and could not get it to work.

+4
source share
3 answers

You might want to look at the setserial command on Linux - with it you can assign a serial port for non-standard speed.

You should be able to disable it if you run seterial as follows before connecting to port initialization (either in server initialization scripts or in your PHP ... although you are not sure if this will be a good idea):

/bin/setserial /dev/ttyS1 spd_cust baud_base 115200 divisor 4

Here's what happens on the team:

  • The spd_cust option tells the OS to set the speed to a custom divider when the application requests 38400.
  • / dev / ttyS1 is the serial port. You change it to anything.
  • baud_base is the number to be used by divisor 4

115200/4 = 28800 ... the speed you need :-)

In your PHP code, you connect to 38400, which seems strange, but due to seterial, the port you specify will work at 28800

+2
source

For windows try

"mode " . $device . " BAUD=" . $baud

For linux try

"stty -F " . $device . " " . $baud

I think these are the right commands to send

+1
source

Source: https://habr.com/ru/post/1312204/


All Articles