obniz to be used
It 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
Calls each of the listeners registered for a given event.
It stops uart and releases io.
// Javascript Example
obniz.uart0.start({tx:0, rx:1})
obniz.uart0.send("Hi");
obniz.uart0.end();
Return an array listing the events for which the emitter has registered listeners.
It 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
}
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Add a listener for a given event.
Add a one-time listener for a given event.
It 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.
Remove the listeners of a given event.
This 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.
Convert data array to string.
data array
converted string. If convert failed, return null.
Generated using TypeDoc
Uart module