Skip to content

Missing support for ArrayBuffer in xs_i2c_write #185

@zBuffer

Description

@zBuffer

Took me a while (and loads of headless chicken debugs) to notice SMB writeBlock doesn't support ArrayBuffer (but readBlock supports it!).

Here's a suggestion modules/pins/i2c/i2c.c:162:

		if(xsmcIsInstanceOf(xsArg(i), xsArrayBufferPrototype))
		{
			l = xsGetArrayBufferLength(xsArg(i));
			if ((len + l) > sizeof(buffer))
				xsUnknownError("40 byte write limit");
			c_memmove(&buffer[len], xsmcToArrayBuffer(xsArg(i)), l);
			len += l;
		}
		else
		{
			xsmcGet(xsVar(0), xsArg(i), xsID_length);
			l = xsmcToInteger(xsVar(0));
			if ((len + l) > sizeof(buffer))
				xsUnknownError("40 byte write limit");
			for (j = 0; j < l; j++) {
				xsmcGet(xsVar(0), xsArg(i), j);
				buffer[len++] = xsmcToInteger(xsVar(0));
			}
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions