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 that the reader beeps means that the reading was done in the reader itself, but it does not mean that the read value was sent to a destination through some interface. If the reader is wireless, it may not even be paired to the computer, but charge the reading if it is energized.
If you have already detected that the reader is paired to the computer, just access the corresponding port and obey the communication protocol. From what I understand, you have already won this step and discovered that the reader is mapped on the door COM7.
Your question does not make it clear what kind of application you are building, whether it is a PHP script running in a command line or whether this code will run on a web page. If the code runs on a web page, remember that it will search for the reader on the COM port of the server running the PHP script, 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. In Windows she is not able to read what comes from the door, just write on the door. Also, this class is experimental and full of bugs, so I wouldn’t trust it to run a real application in production.
I suggest you use another language to connect to the serial port and receive the reading result. Place the code that reads on a service that will run on the machine where the reader is paired. This service can be done using some native language of 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 query. The size of the buffer and the data structure (FIFO, LIFO etc.) will depend on your business requirement, that is, how often the application needs to receive the value read. Your application then searches the value via HTTP GET
in localhost. If it is a web application, just do it via request AJAX when the cursor is positioned in the field, remembering to configure in your service the Header HTTP Access-Control-Allow-Origin
with the page source server, so that the CORS (Cross-Origin Request Sharing)
work.
Once read by the HTTP interface, the value is removed from buffer.
It’s not a trivial solution, but I’ve already developed something similar that runs perfectly on hundreds of customers a few years ago. The downside of this solution is to have to develop and maintain an extra service, in addition to need to monitor this service, to identify if stuck.
fopen
is to open a file, in your case, for reading. Where is the file?– William Aparecido Brandino
I saw some people giving example of opening connection with serial port using "FOPEN", providing only the "COM" as in the example above, ended up testing the code. I have no experience with serial port, bluetooth, so anything is valid to get the desired result rs
– Eduardo
I don’t know if php would be the right language for what you want, but you’ve tried running xampp in administrator mode ?
– Marcos Brinner
What would be the proper language? I ran as ADM, but it remains the same thing.
– Eduardo
I believe python is best to mess with it.... but I’ve never touched it.
– Karl Zillner
https://github.com/karulis/pybluez
– Karl Zillner
I found a demo software that provides the source code VS, but I do not have the slightest dispatch with it. It can communicate with the reader and does not generate any errors. I found other softwares too, and in common, all use the "Rfidreaderlibrary.dll".
– Eduardo
When you turn on your Bluetooth device, it will be available to be "viewed" by your computer. At this time you should pair this device (don’t forget to enable Bluetooth before your computer). Only then can you open a connection to the device, in whatever language. Done pairing, then you should check which port
COM
the device is enabled. There yes you indicate in your code the right port. Tip: Before encoding, try opening the connection with a type programPuTTy
or similar.– wBB
@wBB, all the procedures you quoted I was already doing, the only test I didn’t do was with the Putty, but I understand that if it didn’t work with the CMD which is "weightless", it probably won’t work on the Putty either.
– Eduardo
@I used Putty to open COM and it worked.
– Eduardo
I even managed to send the commands to start reading the tags, abort, and it worked well for Putty.
– Eduardo
This means that the problem is neither on your device, nor on the COM port of your PC, nor on the communication itself. From where you conclude that you’re in the programming part. I don’t have a test for you, but another suggestion would be to use a different language to know if it works or, if you want to insist on PHP, try other methods. If you’re going to use C language, there are a lot of examples about serial communication ready on the NET and you could quickly test.
– wBB
There are demos in C, C#, that work the communication, perform the reading, etc, my problem is q would be to use in an existing PHP system, so I’m seeing the possibilities.
– Eduardo
Even if it is a PHP system it would be possible to use python, since python is native linux and PHP could call it via shell
– Karl Zillner
If your device generates logs in some TXT in windows, it would be nice to consider reading the Log instead of connecting on the device with PHP. If you can generate this log, you could even do something asynchronous with a server and have the data in real time in the cloud.
– David Dias