• Okay.. i think it works now. I uploaded the module on my github so its easy to share.
    Try this example to get you started:

    let GT511 = require('https://github.com/PaddeK/espru­ino-gt511cxx/blob/master/gt511cxx.js');
    
    let serial = Serial.find(B7);
    serial.setup(9600, {rx: B7, tx: B6});
    
    let g = new GT511(GT511.Devices.GT511C1R, serial),
        open = () => g.open(),
        close = () => g.close(),
        getTemplate = (t) => () => g.getTemplate(t);
    
    let base64Enc = (bytes) => btoa(bytes.reduce((p, c) => p + String.fromCharCode(c), '')),
        base64Dec = (string) => E.toUint8Array(atob(string).split(''));
    
    GT511.sequence([open, getTemplate(0), close]).then(result => {
        // result is an array that contains the return values of all functions called in the sequence (in same order)
    
        let template = result[1],
            b64 = base64Enc(template);
    
        console.log('template', template);
        console.log('base64', b64);
        console.log('validate', base64Dec(b64).slice(0, -1).toString() === template.toString()); // something is fishy here
    }).catch(err => console.log(err));
    

    And i guess i found a bug in espruino somewhere.. while converting the template back to a Uint8Array i have to remove a trailing zero.. which i have no clue why it is there in the first place.

  • Hello @PaddeK, thanks for taking your time to try and sort somethings out.
    I'm still getting a timeout error:

    timeout exceeded
    

    I have tried several alternatives in calling the getTemplate function, yet it still times out.

    Also calling the enroll(t) function results in this error:

    Error {
      "msg": "Expecting a function to call, got Object",
      "type": "Error",
      "stack": " at line 1 col 1\nfn().then(res.concat.bind(res))\n^\ni­n function called from system\n"
     }
    

    after setting enroll with enroll = (t) => () => g.enroll(t); and passed it into the GT511.sequence array I got this error

    enroll error:  Error {
      "msg": "Function \"switchLED\" not found!",
      "type": "Error",
      "stack": " at line 1 col 6\nthis.switchLED(!!b)\n     ^\nin function \"fn\" called from line 1 col 4\nfn().then(res.concat.bind(res))\n   ^\nin function called from system\n"
     }
    
About

Avatar for user81574 @user81574 started