Warning: Declaration of action_plugin_indexmenu::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/httpd/vhosts/scratchbook.ch/wiki.scratchbook.ch/lib/plugins/indexmenu/action.php on line 18 Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/wiki.scratchbook.ch/lib/plugins/indexmenu/action.php:0) in /home/httpd/vhosts/scratchbook.ch/wiki.scratchbook.ch/inc/auth.php on line 495 Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/wiki.scratchbook.ch/lib/plugins/indexmenu/action.php:0) in /home/httpd/vhosts/scratchbook.ch/wiki.scratchbook.ch/inc/actions.php on line 210 Wrong encoding on the serial port? [Scratchbook]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sfera:serialport [2016/12/05 14:27]
claude [Wrong encoding on the serial port?]
sfera:serialport [2016/12/08 12:06] (current)
claude [Suddenly, it works]
Line 74: Line 74:
  
 {{:​sfera:​weather-station.png?​nolink|}} {{:​sfera:​weather-station.png?​nolink|}}
 +
 +===== Suddenly, it works =====
 +
 +<​code>​
 +root@raspberrypi:​~/​dali#​ coffee wetter.coffee 40
 +undefined
 +<Buffer 57 2b 32 34 2e 34 30 30 30 30 30 30 4e 34 39 39 30 31 2e 32 4e 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 32 30 31 35 03>
 +<Buffer 57 2b 32 34 2e 34 30 30 30 30 30 30 4e 34 39 38 30 31 2e 32 4e 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 32 30 31 34 03>
 +<Buffer 57 2b 32 34 2e 34 30 30 30 30 30 30 4e 34 39 38 30 31 2e 32 4e 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 32 30 31 34 03>
 +<Buffer 57 2b 32 34 2e 34 30 30 30 30 30 30 4e 34 39 37 30 31 2e 32 4e 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 32 30 31 33 03>
 +<Buffer 57 2b 32 34 2e 34 30 30 30 30 30 30 4e 34 39 37 30 31 2e 32 4e 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 32 30 31 33 03>
 +^
 +
 +<Buffer 57 2b 32 35 2e 31 30 30 30 30 30 30 4e 35 36 35 30 30 2e 35 4e 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 32 30 30 39 03>
 +1: W
 +2: +
 +3: 2
 +4: 5
 +5: .
 +6: 1
 +7: 0
 +8: 0
 +9: 0
 +10: 0
 +11: 0
 +12: 0
 +13: N
 +14: 5
 +15: 6
 +16: 5
 +17: 0
 +18: 0
 +19: .
 +20: 5
 +21: N
 +22: ?
 +23: ?
 +24: ?
 +25: ?
 +26: ?
 +27: ?
 +28: ?
 +29: ?
 +30: ?
 +31: ?
 +32: ?
 +33: ?
 +34: ?
 +35: ?
 +36: 2
 +37: 0
 +38: 0
 +39: 9
 +40:
 +</​code>​
 +
 +<​code>​
 +SerialPort = require '​serialport'​
 +
 +port = new SerialPort "/​dev/​ttyAMA0",​
 +        baudRate: 19200
 +        dataBits: 8
 +        stopBits: 1
 +        parity: '​none'​
 +        rtscts: true
 +        xon: true
 +        xoff: true
 +        xany: true
 +        #parser: SerialPort.parsers.readline 0xf9
 +        parser: SerialPort.parsers.byteLength process.argv[2]
 +        #parser: SerialPort.parsers.raw
 +        #parser: SerialPort.parsers.byteDelimiter [0xf9]
 +
 +port.on '​open',​ (data) ->
 +        console.info data
 +
 +port.on '​error',​ (data) ->
 +        console.info "​error:​ ", data
 +
 +port.on '​data',​ (data) ->
 +        console.info data
 +        i = 1
 +        for d in data
 +                console.info "#{i}: #​{hex2ascii(d)}"​
 +                i++
 +
 +dec2bin = (dec) ->
 +        (dec >>>​ 0).toString(2)
 +
 +hex2ascii = (hex) ->
 +        String.fromCharCode hex
 +
 +</​code>​
sfera/serialport.1480944474.txt ยท Last modified: 2016/12/05 14:27 by claude
Back to top
GNU Free Documentation License 1.3
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0