K
K
Kindman2011-05-07 11:33:12
PHP
Kindman, 2011-05-07 11:33:12

How to deflorate the COM port of a GPS navigator in Windows using regular PHP tools?

My modem in Windows hangs on COM8.
I connect to it via PHP-CLI something like this:

<?php
$com=8;
$mdm="\\\\.\\COM$com";
[email protected]($mdm,"a+b");
//tty_setraw($con);
fwrite($con,"AT\r");
while (1)
  echo fread($con,1);

As a result, the modem outputs the line "OK".
All this works fine, but only after I:
  1. I go to "Start / Control Panel / Phone-and-modem",
  2. select the "Modems" tab,
  3. poke the mouse into your modem from the list,
  4. click the "Properties" button,
  5. Select the "Diagnostics" tab
  6. press the "Query modem" button and
  7. waiting for a response from the modem...

Without these dances with tambourines, not a single byte of data can be pulled out of the modem.
The only reassurance is that this magical "ritual" of initiating the modem needs to be done only once after connecting the modem to the computer (before using the port for the first time).
After that everything works just great!
Moreover, I tried it on different USB and Blutooth modems, and in different Windows (xp and 7), and even in different versions of PHP (5.2 and 5.3).
The result is the same everywhere.
Everything would be great if not for a single detail:
The other day I got a GPS-navigator, which took pride of place COM9 in the system.
When trying to connect to it using a PHP-CLI script, similar symptoms are observed, as in the case of a pristine modem.
But, unlike the case with the modem, there was no suitable tool in the control panel, such as "GPS navigators".
That is, you now need to download some kind of “left” software in order to flatten the GPS.
I was looking for a solution to this problem:
for example, in PYTHON there is a method for this that is
tty.setraw(fd)
launched immediately after opening the port descriptor.
I already wanted to specifically install Python 3.2 for this, but I would like to understand what exactly happens to the port during "setraw" and during the modem poll from the control panel.
Question: what should be written inside the body of a PHP function
function tty_setraw($con)
    {
    //some magic
    }

so that it was not necessary to carry out the rituals described above every time?
ps: In the language with the SmokinMarlboro habrauser , the following solution was proposed: m.habrahabr.ru/post/119030/

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vertexodessa, 2013-10-15
@Vertexodessa

you need to send the “at” command several times so that the modem determines the speed at which it is going to communicate with it

Y
YourChief, 2011-05-07
@YourChief

in Python, this function works as an intermediary to tcsetattr, look towards php.net/manual/en/function.dio-tcsetattr.php

A
Alexey Zhurbitsky, 2011-05-07
@blo

try to play around with the mode console command , if something works out, then inside tty_setraw there will be an exec with the resulting command.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question