-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtests.ts
36 lines (27 loc) · 869 Bytes
/
tests.ts
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
// this test runs on the device, connect and it will send the output on serial
// after everything is done
// run pxt test & copy build/binary.hex to MINI drive
// log AT commands to USB console
const DEBUG_AT = true;
//% shim=pxtrt::panic
function panic(code2: number): void {
}
function assert(msg: string, cond: boolean) {
if (!cond) {
modem.log("ASSERT:", msg + " failed");
panic(45);
} else {
modem.log("TEST:", msg + ": OK");
}
}
console.log("TEST START");
// test modem functionality
modem.enableDebug(DEBUG_AT);
// initialize module
modem.init(SerialPin.C17, SerialPin.C16, BaudRate.BaudRate9600);
// some modems have quirks:
modem.setATPrefix("\rAT");
assert("modem AT -> OK", modem.expectOK(""));
assert("modem AT+TRASH -> ERROR", !modem.expectOK("+TRASH"));
serial.resetSerial();
console.log("TEST FINISHED OK");