forked from jadonk/bonescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserial.js
More file actions
25 lines (23 loc) · 686 Bytes
/
Copy pathserial.js
File metadata and controls
25 lines (23 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (C) 2013 - Texas Instruments, Jason Kridner
var bone = require('./bone');
var my = require('./my');
var m = {};
m.name = 'serialport';
m.module = my.require('serialport');
m.ports = bone.uarts;
m.events = {
'open': [],
'data': ['data']
};
m.openPorts = {};
m.doOpen = function (args) {
var path = args.port;
if (m.ports[args.port].path) path = m.ports[args.port].path;
var openPort = new m.module.SerialPort(path, args.options);
return (openPort);
};
module.exports = {
serialOpen: my.wrapOpen(m, ['options']),
serialWrite: my.wrapCall(m, 'write', ['data'], ['err', 'results']),
serialParsers: m.module.exists ? m.module.parsers : {}
}