II Perl code hangs after specific number of AT requests

After connecting to a Bluetooth OBD-II adapter, I am able to get data by sending PID service requests, but they stop exactly after the same number of requests.

for ( ;; ) {
    obj -> write ( "010Cr" );
    if ( $data = $obj -> input ) {
        print "$data";
    }
    obj -> write ( "010Dr" );
    if ( $data = $obj -> input ) {
        print "$data";
    }

}

Can you please let me know what could be the problem? I read somewhere about two options 1) Re-initializing and 2) about buffer left with CRs. I am looking into those.

(I used Torque on my android with the same OBD-II Bluetooth adapter and it seems to get the data continuously. So there must be something wrong in what I am doing).

Thank you for any response.

链接地址: http://www.djcxy.com/p/95120.html

上一篇: Android蓝牙OBDII通信

下一篇: II Perl代码在特定数量的AT请求后挂起