obniz to be used
Optional onreceiveIt is called when data is received. Data is array of bytes. Text is the same data but in text representation.
So, if obniz Board receives 'A'.
// Javascript Example
obniz.uart0.start({tx:0, rx:1})
obniz.uart0.onreceive = function(data, text) {
console.log(data);
console.log(text);
}
obniz.uart0.send("Hello");
Rsponse waiting timeout in milliseconds
Static prefixedOptional context: anyIt checks if there are data received but not yet used. If there are, it returns true.
If you are using onreceive callback, it will always be false because you receive the data with the callback function as the data arrives.
// Javascript Example
obniz.uart0.start({tx:0, rx:1})
while(1){
if(obniz.uart0.isDataExists()){
console.log(obniz.uart0.readText());
}
await obniz.wait(10); //wait for 10ms
}
Optional fn: ListenerFnOptional context: anyOptional once: booleanAdd a listener for a given event.
Optional context: anyAdd a one-time listener for a given event.
Optional context: anyIt returns the one byte that are received but not yet used.
// Javascript Example
obniz.uart0.start({tx:0, rx:1})
while(1){
if(obniz.uart0.isDataExists()){
console.log(obniz.uart0.readBytes());
}
await obniz.wait(10); //wait for 10ms
}
received data. If not exist data, return null.
It returns the data array that are received but not yet used.
// Javascript Example
obniz.uart0.start({tx:0, rx:1})
while(1){
if(obniz.uart0.isDataExists()){
console.log(obniz.uart0.readBytes());
}
await obniz.wait(10); //wait for 10ms
}
received data. If not exist data, return [].
It returns the data that are received but not yet used as string.
// Javascript Example
obniz.uart0.start({tx:0, rx:1})
while(1){
if(obniz.uart0.isDataExists()){
console.log(obniz.uart0.readText());
}
await obniz.wait(10); //wait for 10ms
}
received text data. If not exist data, return null.
Remove all listeners, or those of the specified event.
Optional event: stringRemove the listeners of a given event.
Optional fn: ListenerFnOptional context: anyOptional once: booleanThis sends data.
Available formats are
string utf8 encoded byte array. Does not include null terminate
number will be one byte data
array of number array of bytes
Buffer array of bytes
// Javascript Example
obniz.uart0.start({tx:0, rx:1})
obniz.uart0.send("Hi");
obniz.uart0.send(0x11);
obniz.uart0.send([0x11, 0x45, 0x44]);
It starts uart on io tx, rx.
You can start uart without much configuration. Just use as below.
Generated using TypeDoc
Uart module