If you need to send or receive bytes to or from an LJM-supported device, consider using the LJM ByteArray functions.
These functions automatically split writes or reads into multiple packets, if necessary. Because of this, you can write or read a large number of bytes without worrying about what the maximum packet size of the connection is. This is especially useful for buffer registers. For example:
- Writing or reading serial protocols like SPI, I2C, SBUS, 1-Wire, or Asynchronous Serial (UART)
- Writing a Lua script and reading the Lua output
- Writing or reading file paths on device SD cards
Name versions:
Address versions:
Example
[C/C++] Use LJM_eWriteNameByteArray to write a Lua script to device
int LJMError; int ErrorAddress; const char * luaScript = Â Â "LJ.IntervalConfig(0, 1000)\n" Â Â "while true do\n" Â Â " Â if LJ.CheckInterval(0) then\n" Â Â " Â Â print(LJ.Tick())\n" Â Â " Â end\n" Â Â "end\n" Â Â "\0"; const unsigned scriptLength = strlen(luaScript) + 1; // handle comes from LJM_Open() LJMError = LJM_eWriteAddressByteArray( Â Â handle, Â Â LUA_SOURCE_WRITE_ADDRESS, Â Â scriptLength, Â Â luaScript, Â Â &ErrorAddress ); if (LJMError != LJME_NOERROR) { Â Â // Deal with error }
See the LJM C/C++ examples download for a full example.