forked from andyli/hxSerial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.hx
39 lines (31 loc) · 865 Bytes
/
Test.hx
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import hxSerial.Serial;
import haxe.io.BytesOutput;
import Sys;
class Test extends haxe.unit.TestCase{
public function test():Void {
trace("start testing...");
trace(Serial.getDeviceList());
var s = new Serial("/dev/tty.usbserial-A4001tkb",true);
//this.assertTrue(s.isSetup);
Sys.sleep(2);
for (i in 0...2){
this.assertTrue(s.writeByte(65));
Sys.sleep(1.5);
this.assertEquals(2,s.available());
this.assertEquals(66,s.readByte());
this.assertEquals(67,s.readByte());
}
for (i in 0...2){
this.assertEquals(1,s.writeBytes("A"));
Sys.sleep(1.5);
this.assertEquals(2,s.available());
this.assertEquals("BC",s.readBytes(2));
}
s.close();
}
static public function main():Void {
var runner = new haxe.unit.TestRunner();
runner.add(new Test());
runner.run();
}
}