In this post I will cover five conman utilities used for serial communication under Linux / Unix / *BSD and Mac OS X. Find out information about your serial ports Type the following dmesg command. Sep 01, 2011 Re: [SOLVED] Serial port dropping bytes 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.
The following is a library for serial communications via PHP: http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html. The problem is that the method readPort is not fully implemented. It can read in a *nix environment, but apparently not in a Windows environment. The method:
The author states:
> /! WARNING /! : it's working with linux for r/w, but with windows i've only been able to make write working. If you're a windows user, try to access the serial port through network with serproxy instead.
The limitation of the PHP class library has been mentioned in SO several times already. I haven't found a decent solution. Reading is imperative for my application.
Does anyone here know what to do?
dsolimano2 Answers
If you can guarantee that you're on Windows, I might recommend an interesting approach: Use either COM (as in, Microsoft's COM, not serial port) or .NET.
There's a free .NET class that I regularly use called CommStudio Express. I've found it to be very reliable, but you can always use the standard SerialPort class built into .NET if you don't need to worry about a USB-to-serial adapter getting unplugged randomly.
In any case, it's easy enough to get at a .NET class in PHP with the DOTNET class:
I haven't tested this code (not on Windows at the moment), but something like that should work just fine. You can then proceed to use all of the regular .NET methods within PHP.
Nope, DOTNET hangs the COM Port. You need to either Restart the computer to detect again or Advanced Users generally Uninstall and Install Arduino.
Not the answer you're looking for? Browse other questions tagged phpserial-port or ask your own question.
I am confused about the these 3 concepts.
My understanding is, Serial Port
usually means RS-232 compatible port (RS = Recommended Standard). USB
stands for Universal Serial Bus
. So its name contains serial port, does it support RS-232? What does the Universal
mean?
And what does COM port mean?
ADD 1
Some understanding from Hans' answer:
To reduce effort, device manufacturers usually make their device can behave like a serial port device as well. This relies on the the fact that many OS and language libraries have already included serial port communication support. Though such support is no comparable to a real matching device driver.
ADD 2
A good reference doc about Serial Port HOW-TO.
And btw, the Linux Document Project is really useful.
smwikipediasmwikipediaclosed as off-topic by Pang, Yu Hao, Klaster_1, Ravi Dhoriya ツ, EdChumJan 16 '15 at 8:52
This question appears to be off-topic. The users who voted to close gave this specific reason:
- 'Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User.' – Pang, Yu Hao, Klaster_1, Ravi Dhoriya ツ, EdChum
2 Answers
Serial port
is a type of device that uses an UART chip, a Universal Asynchronous Receiver Transmitter. One of the two basic ways to interface a computer in the olden days, parallel ports were the other way. Serial is simple to hook up, it doesn't need a lot of wires. Parallel was useful if you wanted to go fast, typ 8 times faster than serial, but cables and connectors were expensive. Parallel I/O has completely disappeared from computer designs, caught up by tremendous advances in bus transceivers, the kind of chip that can transmit an electrical signal down a wire.
COM
comes from MS-Dos, it is a device name. Short for 'COMmunication port'. Computers in the 1980's usually had two serial ports, labeled COM1 and COM2 on the back of the machine. This name was carried forward into Windows, most any driver that simulates a serial port will create a device with 'COM' in its name. LPT
was the device name for parallel ports, short for 'Line PrinTer'.
RS-232
was an electrical signaling standard for serial ports. It is the simplest one with very low demands on the device, supporting just a point-to-point connection. RS-422 and RS-485 were not uncommon, using a twisted pair for each signal, providing much higher noise immunity and allowing multiple devices connected to each other.
USB
means Universal Serial Bus. Empowered by the ability to integrate a micro-processor into devices that's a few millimeters in size and costs a few dimes. It replaced legacy devices in the latter 1990s. It is Universal because it can support many different kinds of devices, from coffee-pot warmers to disk drives to wifi adapters to audio playback. It is Serial, it only requires 4 wires. And it is a Bus, you can plug a USB device into an arbitrary port. It competed with FireWire, a very similar approach and championed by Apple, but won by a land-slide.
The only reason that serial ports are still relevant in on Windows these days is because a USB device requires a custom device driver. Device manufacturers do not like writing and supporting drivers, they often take a shortcut in their driver that makes it emulate a legacy serial port device. So programmers can use the legacy support for serial ports built into the operating system and about any language runtime library. Rather imperfect support btw, these emulators never support plug-and-play well. Discovering the specific serial port to open is very difficult. And these drivers often misbehave in impossible to diagnose ways when you jerk a USB device while your program is using it.
Hans PassantHans PassantUSB stand for Universal Serial Bus not Port. The term 'serial port' simply means that the data is transferred one bit at a time over a single signal path - in that sense even Ethernet is serial in nature. The word serial in both terms implies no relationship other the width of the data path.
You are right in that the term serial-port in the context of a PC normally means an RS-232 port, but there are other serial port standards such as RS-422 and RS-485 often used in industrial applications. What these have in common is that they are implemented using a UART (Universal Asynchronous Receiver/Transmitter).
The term Universal in USB merely reflects the fact that it is not a specific device interface such as the dedicated mouse or keyboard ports found on older hardware. Similarly a UART based serial port is not device specific, reflected by the U in UART.
USB differs significantly from RS-232 in a number of ways; it is a master/slave (or host/device in USB terminology), rather than peer-to-peer, the USB device cannot initiate communication, it must be polled by the host. USB includes a low-voltage power supply to allow devices with moderate power requirements to be powered by the bus - that is also why USB ports can be used for charging battery powered devices. USB is significantly more complex that RS-232 which defines only the physical (hardware) layer whereas USB requires a complete software protocol stack.
Linux Serial Port Example
The term COM is just a device name prefix used in Windows (and previously MS-DOS) for a serial (UART) port. Short for 'communications', you can for example open a COM port as a stream I/O device with say FILE* port = fopen( 'COM1', 'wr' ) ;
.