Php serial communication in linux. I have installed xampp in fedora 13.I am trying to communicate with microcontroller through serial port using php serial class. How To Check and Use Serial Ports Under Linux last updated January 28, 2010 in. Irq, linux box, linux serial port, linux serial port communication, linux serial port console, linux serial port monitor, modem. How to compile and install Linux Kernel 4.18.1 from source code; Linux iotop Check What's Stressing Increasing Load On Hard Disks. RS232 serial port communication in kernelspace. Ask Question. I think this link can give you a good overview of the Linux kernel serial driver architecture. But if you feel you cannot you may want to look at things in the kernel which do use the serial port, for example the serial.
I have a piece of simple code that works on a Windows - WAMP environment, e.g. It connects via a USB cable (using USB-Serial drivers) to a circuit-board to light some LEDs, and it works fine - so similarly windows software like 232Analyser, can connect to COM3 and send code in DEC like 1,255,255,255,255,5, and light the LEDs. The number 255, is a DEC number from: 1,2,4,8,16,32,64,128,255 which will light a certain LED depending on which number is called.
Anyway, the code above works fine on Windows, and lights LEDs by calling this PHP file. So can call a URL like: which works ok. Now I need it to work via Linux, on a Raspberry Pi, so I have just installed standard Raspberry Linux, and Apache with PHP. Then attached the USB cable, and it appears as /dev/ttyUSB0 I have then CHMOD 777 /dev/ttyUSB0 And changed the PHP code to: However calling this file on Linux in a browser is not Lighting the LEDs, as it does on Windows. Now when I call this file it goes through with no errors, without chmod 777, it gave a permission denied error. So it seems like it goes through ok, but something else is wrong.
So question is anyone know how to make it work on Linux, it might be I am calling the USB wrong, or Raspberry Linux needs some kind of drivers, or ' `mode ' needs to be defined differently.or maybe the decimal/binary code sent is not right like 'chr(2)' etc. Needs to be different and wont be sent in same way on a LAMP setup.
Any ideas on what I can try?
I am doing some embedded systems development work and I have an FTDI USB to Serial bridge chip on the board I am working on. It randomly drops received bytes.
This only happens under Arch linux as I just recently switched from Ubuntu and I had no problems there. I have the same problem on another computer I use that also runs Arch, though the problem there is much worse.
I'm assuming it's a kernel interrupt priority issue. I don't really know where to start debugging this, so any input would be much appreciated. Unfortunately, it's quite random.
Sometimes it's rock solid and sometimes it drops a byte every few hundred or so, causing some rather anoying issues. Cast in point: it seems to be working fine at the moment but earlier it was wreaking havoc while I was tring to carry out some calibration operations. The other computer I tried it with is consistently bad, though, getting out of sync almost immediately. The first computer (usually good performance) has a high end 2nd gen core i7 (sandy bridge) while the second (not so good performance) computer has an intel atom processor.
Last edited by alex.forencich (2011-09-01 07:07:02). I did some testing on my eee pc (same one as the previous post with an atom processor). In Ubuntu, the connection is rock solid. Didn't drop a single byte in 10 minutes of heavy data transfer. However, in Arch, it consistently drops at least one byte within 2 minutes and breaks the synchronization between the desktop application and the board. Now, I am going to add checks to reset the connection if it comes out of sync, but I really want to figure out what the underlying cause is here since it's definitely not a problem with the USB-serial chip or my firmware.
The device on the other end is an Atmel xmega microcontroller. I did not use any flow control when I wrote the firmware as the communication routines in the firmware are very fast as the chip runs at 32 MHz and the USART is interrupt driven. Since only one byte at a time gets dropped, the chip is definitely receiving and responding to the bytes sent as most of the commands are 3 bytes and the responses are 3 bytes, so more than one byte would get lost if a byte got lost on the way there. As for stty, here are the outputs: Arch. Looks like the bytes sent were 13 04 06 so the 13 got eaten somewhere. As hex 13 is XOFF, I tried running stty -F /dev/ttyUSB0 -ixon. This seems to have solved the issue.