Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/modules/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,21 @@ static int spi_send_recv( lua_State *L )
else
{
luaL_Buffer b;
size_t datachars = spi_databits[id] / 8;

if (spi_databits[id] % 8 != 0) {
return luaL_error( L, "attempt to send string with non-character-divisible databits" );
}
if (datalen % datachars != 0) {
return luaL_error( L, "attempt to send string with non-databits-divisible length" );
}

pdata = luaL_checklstring( L, argn, &datalen );
if (recv > 0) {
luaL_buffinit( L, &b );
}

for( i = 0; i < datalen; i ++ )
for( i = 0; i < datalen; i += datachars )
{
if (recv > 0)
{
Expand Down