Dealing with very specific hardware from high level languages is usually a challenge, especially if it is in Web applications. Some considerations about your problem and a suggested solution:
The fact of the beep reader means that the reading was done on the reader itself, but does not mean that the read value was sent to a destination through some interface. If the player is wireless, it may not even be paired with the computer, but read if it is powered up.
If you have already detected that the player is paired with the computer, you should only access the corresponding port and obey the communication protocol. From what I understand, you have already won this step and found that the reader is mapped to COM7.
Your question does not make it clear what kind of application you are building, whether it is a PHP script running on the command line or whether that code will run on a Web page. If the code runs on a Web page, remember it will look for the reader on the COM port of the server where the PHP script runs , not on the Windows client, unless the Web server runs on the Windows client.
Anyway, the PhpSerial class only works in read / write mode on Linux. On Windows it is not able to read what comes from the door, just write on the port. Also, this class is experimental and buggy, so I would not trust it to run an actual application in production.
I suggest you use another language to connect to the serial port and receive the reading result. Put the code that reads into a service that will run on the machine where the reader is paired. This service can be done using some language native to Windows (C #, VB etc.), C, C ++, Java or on top of Node.js, for example.
When the reader beeps, the service receives the result and stores it in a buffer, providing an HTTP interface for querying. The size of the buffer and the data structure (FIFO, LIFO etc.) will depend on your business requirement, ie how often the application needs to receive the read value. Your application then looks up the value via HTTP GET
on localhost. If it is a Web application, just do it via request AJAX when the cursor is positioned in the field, remembering to configure the Header http Access-Control-Allow-Origin
with the source server of the page, so that CORS (Cross-Origin Request Sharing)
works.
Once read by the HTTP interface, the value is removed from buffer .
It's not a trivial solution, but I've already developed something that has worked perfectly with hundreds of customers a few years ago. The negative side of this solution is having to develop and maintain one more service, besides needing to monitor that service, to identify if it has crashed.