Giter Club home page Giter Club logo

plugweb-driver's People

Contributors

dirkengels avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

plugweb-driver's Issues

Fread() Serial error line 92

First i got a directory error, i solved this by moving the driver directory up in the tree.

Now i get:
[Tue Feb 07 21:21:02 2012] [error] [client 127.0.0.1] PHP Warning: fread() expects parameter 1 to be resource, boolean given in /home/marco/www/PlugWeb-Driver/lib/PlugWeb/Driver/Serial.php on line 92

I get this error with the following code:

error_reporting(E_ALL);
ini_set('display_errors', '3');

include('bootstrap.php');

// Example mac addresses
$mac = 'C3XXXC'; //mac (normal) Circle
$macStick = '75XXX8'; //mac Stick

// Initialize stick
$device = new \PlugWeb\Driver\Device($mac, '/dev/ttyUSB0');
$device->initStick();

// Keep switching the light on and off with pauses of 3 seconds
while (true) {
$device->powerSwitch(true);
sleep(3);
$device->powerSwitch(false);
sleep(3);
}

Hope you can help me.

Wrong Checksum

When i request PowerInfo from my devices, some of them doesn't response.

I found that for the devices that didn't response, the checksum was wrong:
sendstring (without checksum):
0012000D6F0000C3A6FC(20)
generated checksum for the above string:
FC0A(4)

Combined send string is:
0012000D6F0000C3A6FCFC0A (24)

sendstring (without checksum):
0012000D6F0000D3198D(20)
generated checksum for the above string:
1BE(3)
Combined send string is:
0012000D6F0000D3198D1BE (23)

The last string is 1 char to short and so i got no response from the circle.

Whats happening here?

Strange character(ƒ) in response string

I'm playing around with you're driver for a few day's now and i got strange responses from the plugs:
"ƒ""square""square""square""square"0013010C000D6F0000C3A6FC001E00F10000A9D800000000000A5B94

The "ƒ" character is messing the whole thing up....

After some debugging, i see the following happening:
received datafrom plug:

"square""square""square""square"0000010C00C11F89 ƒ"square""square""square""square"0013010C000D6F0000C3A6FC001E00F10000A9D800000000000A5B94 < (whiteout the ><)

Formdata translates it with:
$lines = explode("\r\n", $data);

in:
Array
(
[0] => "square""square""square""square"0000010C00C11F89
[1] => ƒ"square""square""square""square"0013010C000D6F0000C3A6FC001E00F10000A9D800000000000A5B94
[2] =>
)

Because of the
"ƒ"

_formdata isn't getting by
" $out['data'] = $this->getResponse()->readString($line);" (device->line312).

Result is that it not generates:
$out['ack']
$out['data']
$out['tmp']

I've tried to modify the $data by replace the ƒ with "" (see first line in function):
protected function _formatData($data) {
$data = str_replace("ƒ","",$data);
$lines = explode("\r\n", $data);
$out = array();
$counter = 0;
foreach($lines as $line) {
if (preg_match('/^00/', substr($line, 4, 4))) {

This isn't working and the ƒ is still showing up.

The following is working, but only for responsive functions (powerinfo, deviceinfo) and not for sending function (switchOn, SwitchOff, switch):
protected function _formatData($data) {
$lines = explode("\r\n", $data);
$out = array();
$counter = 0;
foreach($lines as $line) {
if (preg_match('/^00/', substr($line, 5, 4))) {

NOTE the 5 in the last line!
with this solution I skip the "ƒ" and its start on character 5 with reading the response string.

The only solution (for now) i can think off, is to make 2 _formdata functions:
_formDataSend
_formDataReceive

Each function can handle the send en receive string at its own way.

Do you have a solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.