SPConfig.set

Use mode string for setting baudrate, data bits, parity and stop bits.

Format: "B:DPS" where: B is baud rate D is data bits (5, 6, 7, 8) P is parity ('N' or 'n' -- none, 'E' or 'e' -- even, 'O' or 'o' -- odd) S is stop bits ('1', '1.5', '2')

You can skip baudrate.

example mode strings: "9600:8N1" ":8n1" "7o1.5" "2400:6e2"

Throws

ParseModeException if mode string is badly formatted or using bad values

Examples

SPConfig c;
c.set("2400:7e1.5");
assertNotThrown(c.set(c.mode));
assert(c.baudRate == 2400);
assert(c.dataBits == DataBits.data7);
assert(c.parity == Parity.even);
assert(c.stopBits == StopBits.onePointFive);
c.set("8N1");
assertNotThrown(c.set(c.mode));
assert(c.baudRate == 2400);
assert(c.dataBits == DataBits.data8);
assert(c.parity == Parity.none);
assert(c.stopBits == StopBits.one);
c.set("320:5o2");
assertNotThrown(c.set(c.mode));
assert(c.baudRate == 320);
assert(c.dataBits == DataBits.data5);
assert(c.parity == Parity.odd);
assert(c.stopBits == StopBits.two);

alias PME = ParseModeException;
assertThrown!PME(c.set("4o2"));
assertThrown!PME(c.set("5x2"));
assertThrown!PME(c.set("8e3"));
assertNotThrown!PME(c.set(":8N1"));
assertNotThrown(c.set(c.mode));

Meta