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 687
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 687
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 687
====== Wrong encoding on the serial port? ======
What we get with the logic analyzer:
Time [s],Value,Parity Error,Framing Error
0.591529000000000,W (0x57),,
0.592088833333333,+ (0x2B),,
0.592720333333333,1 (0x31),,
0.593911750000000,9 (0x39),,
0.594445583333333,. (0x2E),,
0.595435166666667,6 (0x36),,
0.595978750000000,0 (0x30),,
0.596512583333333,0 (0x30),,
0.597056250000000,0 (0x30),,
0.597658416666667,0 (0x30),,
0.598202083333333,0 (0x30),,
0.598735916666667,0 (0x30),,
0.599289250000000,N (0x4E),,
0.599901250000000,3 (0x33),,
0.600483916666667,2 (0x32),,
0.601017750000000,3 (0x33),,
0.601587416666667,0 (0x30),,
0.602147333333333,0 (0x30),,
0.602681166666667,. (0x2E),,
0.603315916666667,1 (0x31),,
0.603869250000000,N (0x4E),,
0.604406416666667,? (0x3F),,
0.604940250000000,? (0x3F),,
0.605474083333333,? (0x3F),,
0.606007916666667,? (0x3F),,
0.606541750000000,? (0x3F),,
0.607075583333333,? (0x3F),,
0.607658333333333,? (0x3F),,
0.608192166666667,? (0x3F),,
0.608726000000000,? (0x3F),,
0.609259833333333,? (0x3F),,
0.609793666666667,? (0x3F),,
0.610327500000000,? (0x3F),,
0.610858083333333,? (0x3F),,
0.611392000000000,? (0x3F),,
0.611984416666667,2 (0x32),,
0.612531250000000,0 (0x30),,
0.613074916666667,0 (0x30),,
0.613608750000000,5 (0x35),,
0.614142583333333,'3' (0x03),,
What arrives at /dev/ttyAMA0:
I'm connecting using the same parameters as the decoder in the logic analyzer; baudrate 19200, databits 8, stopbits 1, parity none.
The manual of the weather station says that we should receive exactly 40 bytes, but when I read 40 bytes with Node.js, the whole streamblock gets shifted. I need to read 42 bytes, sometimes 43 bytes.
===== Horizontally represented: =====
00 54 6a 9d 00 63 34 ...
instead of
57 2B 31 39 2E 36 ...
57: W (start bit weather-data)\\
2B 31 39 2E 36: +19.6° (temperature)
It's sent directly as ASCII chars, hex encoded. Unfortunately, something went wrong in /dev/ttyAMA0.
{{:sfera:weather-station.png?nolink|}}
===== Suddenly, it works =====
root@raspberrypi:~/dali# coffee wetter.coffee 40
undefined
^
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:
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