Php Serial Port Communication Linux Wine

Posted on by

Wine + Serial Port? I've installed wine and my programming software, the program runs perfectly, but doesn't list any com ports in the setup menu. There are no errors in the console window when I start the app. This class can be used to communicate with a serial port under Linux or Windows. It takes the path (like '/dev/ttyS0' for linux or 'COM1' for windows) of serial device and checks whether it is valid before opening a connection to it. Once the connection is opened, it can send data to the serial port. If you use Linux and rely on a Windows only serial port application, besides virtualization, you could use Wine. If you configure it, most Windows applications will be able to detect and use the serial ports. This class can be used to communicate with a serial port under Linux or Windows. It takes the path (like '/dev/ttyS0' for linux or 'COM1' for windows) of serial device and checks whether it is valid before opening a connection to it. Once the connection is opened, it can send data to the serial port, and read answers (reading is only implemented for Linux). (PHP 4 >= 4.3.0, PHP 5 serial port. To get my Linux box to talk to an external serial. Aug 03, 2013  wine's serial port support is still incomplete, USB completely unsupported (regarding devices that need windows hardware drivers installed to work properly). From application is communication done only through serial port. To answer your question, on windows it is needed to install usb to serial converter driver.

Active6 years, 6 months ago

Membersihkan catridge hp deskjet j1000. I am trying to communicate with a micro controller trough a serial port under Linux.I am using a USB to serial cable for the purpose, but my php script is giving me the following error:

Fatal error: Call to undefined function deviceSet()

Here is my script

I have my doubts that the php_serial.class file has trouble running the serial connection through USB, any ideas?

Also it seems like there is a problem with this:

Thanks.

I edited the $serial ->deviceSet() and now a bunch of errors appear

Specified serial port is not valid in /var/www/html/php_serial.class.php on line 111 Warning: Unable to set the baud rate : the device is either not set or opened in /var/www/html/php_serial.class.php on line 204 Warning: Unable to set parity : the device is either not set or opened in /var/www/html/php_serial.class.php on line 254 Warning: Unable to set length of a character : the device is either not set or opened in /var/www/html/php_serial.class.php on line 298 Warning: Unable to set the length of a stop bit : the device is either not set or opened in /var/www/html/php_serial.class.php on line 335 Warning: Unable to set flow control mode : the device is either not set or opened in /var/www/html/php_serial.class.php on line 376 Warning: The device must be set before to be open in /var/www/html/php_serial.class.php on line 137 Warning: Device must be opened to read it in /var/www/html/php_serial.class.php on line 474

Is this a problem with the php_serial.class

user2137005
user2137005user2137005

1 Answer

deviceSet() is a method of the serial class. The way you're calling it, it would need to be a native PHP function.

Hp wireless keyboard and mouse driver windows 8.1. It should be: $serial->deviceSet('ttyUSB0');

mkaatmanmkaatman
4,4891 gold badge24 silver badges46 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged phplinuxserial-portusb or ask your own question.

PHP Serial was written at a time where I did not know any other language thanPHP and I started to get seriously bored with its abilities.

Linux Serial Port Read

I somehow got hold of a « Citizen C2202-PD » point-of-sale display, and I wantedto play around with it. I also managed to get the documentation of it, andcreated a convenience class to access the serial port though the Linux file.

Afterwards, I posted it to PHP Classes,and this probably is what brought it any visibility.

Example

State of the project

Port

Interestingly enough, this piece of code that is widely untested has created alot if interest ever since it was created, and especially nowadays witheverybody toying around with Arduinos and Raspberry Pis. I receive about 1 emailevery month asking for help with the code or sending patches/suggestions.

I think that it is time for me to remove the dust off this project and to giveit a full visibility on modern tools, aka GitHub.

Bugs

There is lots of bugs. I know there is. I just don't know which are they.

Platform support

  • Linux: the initially supported platform, the one I used. Probably the lessbuggy one.
  • MacOS: although I never tried it on MacOS, it is similar to Linux and somepatches were submitted to me, so I guess it is OK
  • Windows: it seems to be working for some people, not working for someothers. Theoretically there should be a way to get it done.

Concerns

I have a few concerns regarding the behaviour of this code.

  • Inter-platform consistency. I seriously doubt that all operations go the sameway across all platforms.
  • Read operations. Reading was never needed in my project, so all the tests Idid on that matter were theoretic. I was also quite naive, so the API isprobably not optimal. What we need is to re-think reading from scratch.
  • Configuration done by calling functions. This is so Java. It would be muchbetter to be able to pass a configuration array once and for all. Furthermore,I suspect that the order of call matters, which is bad.
  • Auto-closing the device. There is an auto-close function that is registeredat PHP shutdown. This sounds quite ridiculous, something has to be done aboutthat.
  • Use exceptions. Currently there is an heavy use of the errors system to reporterrors (2007 baby), but this is seriously lame. They have to be replaced byactual exceptions.

Linux Serial Port Communication

Call for contribution

I have about 0 time to code or test this project. However, there is clearly aneed for it.

As in all open-source projects, I need people to fit this to their needs and tocontribute back their code.

Port

What is needed, IMHO:

  • Address the concerns listed above, and find new ones.
  • Create a reproducible test environment for each OS, and prove that eachfeature works (basically, unit-testing).
  • Report of use cases, bugs, missing features, etc.

If you feel like doing any of those, do not hesitate to create an issue or apull-request, I'll gladly consider consider it :)

Licence

PHP SerialCopyright (C) 2007-2014 PHP Serial's contributors (see CONTRIBUTORS file)

This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.

Serial Port Communication Software

This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.

You should have received a copy of the GNU General Public License alongwith this program; if not, write to the Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.