Php Serial Port Communication Linux Distro
Apr 30, 2012 php serial communication in linux. Arduino Forum Using Arduino Programming Questions php serial communication in. I have installed xampp in fedora 13.I am trying to communicate with microcontroller through serial port using php serial class. My code is example.php(find the attachment).On opening example.php through firefox the code is. Serial port communication on linux with javascript or php. Ask Question. Possible duplicate of PHP serial port data return from Arduino, php read data from serial port on linux, php serial communication in linux, etc. – jww Jul 2 at 2:21. Add a comment Is this question similar to what you get asked at work?
Linux Serial Port Tool
First of all, let's assume that you have already connected the serial port of your Linux box to a switch console port via a serial cable.
To connect a Linux terminal to the serial port of your Linux system, you can use a command-line screen manager tool called screen.
Install screen on Linux
To install screen on Debian, Ubuntu or Linux Mint:
To install screen on CentOS, Fedora, or RHEL:
Connect to a Serial Port with screen utility
Traditionally in Linux, the first serial port (COM1) is assigned a name /dev/ttyS0, the second serial port (COM2) assigned /dev/ttyS1, etc. If you specify a serial port name as the first argument of the screen command, the current terminal window where you run screen will be directly connected to the serial port.
Thus, to connect to a serial port, simply run the following command from a terminal:
Optionally, you can specify baud rate (e.g., 1200, 9600, 19200) as the second parameter as follows.
Once connected to a serial port, you will then be able to access the switch console port from the terminal.

To terminate the current screen session, type 'Ctrl-A'+'k'. If you want to temporarily detach from the screen session, type 'Ctrl-A'+'d'. After detached, you can re-attached to the session later by running:
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
How to use the APF's serial ports on Linux.
- 4Sending/Receiving data
Generalities
On Linux, all serial ports are driven the same way. Only their device nodes are changing to reflect the port type:
- i.MX processor internal ports:
- on APF9328, APF27, APF51 & OPOS6UL: /dev/ttySMXN (with kernels <= 2.6.29) or /dev/ttymxcN (with kernels > 2.6.29)
- on APF28: /dev/ttySP[0-4] (general purpose serial ports) or /dev/ttyAMxx (debug serial ports)
- /dev/ttyUSBN for USB <-> serial converters
- /dev/ttySnN for 16550 compatible FPGA's IP
Console port
- Console port is the default serial port on which you can interact with the board (U-Boot and Linux):
- it is serial port 0 (-> /dev/ttySMX0 or /dev/ttymxc0) on APF9328, APF27 & OPOS6UL
- it is serial port 2 (-> /dev/ttymxc2) on APF51
- it is debug serial port 0 (-> /dev/ttyAM0 (2.6.35 kernel) or /dev/ttyAMA0 (3.x kernels)) on APF28
- So, without software modifications, this port is not available to connect a MODEM or any other RS-232 device. If you want to use it as a normal serial port on Linux then:
- be sure that your device won't send data back in response of U-Boot boot's sequence
- change U-Boot consoledev envt variable, to tell Linux to display console on the LCD (for example):
Changing serial ports configuration
- To get current configuration (adapt serial port device name depending on your board, here ttymxc0):
- To only get actual speed:
- By default serial ports are configured as terminal emulator (canonical mode). If you want to use them as 'raw' serial port you will have to do first (example for port 1):
- To change baudrate of port 2 to 115200 :
Sending/Receiving data
In Linux console
- It is as simple as opening the device as a file and writing data to it:
- To receive data (ASCII in that case):
With terminal (miniterm.py)
By default, a simple terminal named «miniterm.py» is installed in the BSP. To use it on OPOS6UL, launch it with /dev port name and speed :
On OPOS6UL_DEV if Rx/Tx are not in loop, nothing will be prompted on key input. To see something prompted the Rx/Tx must be plugged together with a jumper on RaspberryPi connector (pin 8 and 10).
Statistics
- To have some statistics on serial port usage: