Creates a new serial connection and returns its index or -1 if connection failed.
Returns whether the given Arduino is connected.
Closes connection and destroys the given Arduino.
Closes connections and destroys all the Arduinos.
This is a "cheat sheet" for Arduino extension by Buff, updated by YellowAfterlife.
The extension can be found on GitHub.
Creates a new serial connection and returns its index or -1 if connection failed.
Returns whether the given Arduino is connected.
Closes connection and destroys the given Arduino.
Closes connections and destroys all the Arduinos.
Classic functions:
Reads length bytes from the Arduino and returns them as a string.
Returns "" if Arduino doesn't exist, is not connected, or data cannot be read.
Reads bytes from the given Arduino until it encounters a delimiter byte (provided as a string).
Delimiter is not returned as part of the resulting string.
Returns "" if Arduino doesn't exist, is not connected, or data cannot be read.
Reads data until a new line (\n, byte 10) and returns it as a string.
Returns "" if Arduino doesn't exist, is not connected, or data cannot be read.
Slight updates:
Reads up to length bytes from the given Arduino and returns them as a string.
Returns undefined in case of trouble.
Like arduino_read_to, but takes delimiter as a byte value
(so ord(" ") or 32 instead of a " ") and returns undefined
in case of trouble (to tell apart from an empty string).
Like arduino_read_line, but returns undefined in case of trouble.
Buffers:
Reads up to len bytes to a buffer (placed at position pos and onward).
Returns the number of bytes read.
Special return values:
-1: Arduino does not exist
-2: Arduino is not connected
Reads up to len bytes to a buffer (placed at position pos and onward),
stops at delim_u8 byte (not added to the buffer / counted towards return).
Returns the number of bytes read.
Special return values:
-1: Arduino does not exist
-2: Arduino is not connected
Primitives:
The naming convention of the following mimics the buffer_* constants
and they are used much like those in buffer_read - so
arduino_read_u8(ind) reads an unsigned byte,
and arduino_read_s16(ind) reads a signed 16-bit integer.
Functions return undefined in case of trouble.
Reads a NUL-terminated string.
Technically this is just arduino_read_to_new(index, 0).
Classic functions:
Writes length bytes from the buffer
(either a string or buffer_get_address) to the given Arduino.
This function is kept around for backwards compatibility, is unsafe, and I encourage you to use arduino_write_string, arduino_write_text, or arduino_write_buffer depending on what you're after.
Return values:
1: Success
0: Failed to write
-1: Arduino does not exist
-2: Arduino is not connected
New functions:
Writes a NUL-terminated string to the given Arduino.
Return values:
1: Success
0: Failed to write
-1: Arduino does not exist
-2: Arduino is not connected
Writes an unterminated string to the given Arduino.
When storing string length separately from the string,
remember to use string_byte_length so that non-Latin characters don't break your code!
Return values:
1: Success
0: Failed to write
-1: Arduino does not exist
-2: Arduino is not connected
Writes len bytes from the buffer to the given Arduino, starting at pos.
Return values:
1: Success
0: Failed to write
-1: Arduino does not exist
-2: Arduino is not connected
Primitives:
The naming convention of the following mimics the buffer_* constants
and they are used much like those in buffer_write - so
arduino_write_u8(ind, 50) writes 50 as a byte
and arduino_write_s16(ind, 150) writes 150 as a signed 16-bit integer.
Return values:
1: Success
0: Failed to write
-1: Arduino does not exist
-2: Arduino is not connected