MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / execute

Method execute

modules/drivers/sakuraio/sakuraio.js:177–194  ·  view source on GitHub ↗
(cmd, request = null, responseLength = 0)

Source from the content-addressed store, hash-verified

175
176 // internal
177 execute(cmd, request = null, responseLength = 0) {
178 if (request)
179 this.write(cmd, request.length, request, request.reduce((a, b) => a ^ b, cmd ^ request.length));
180 else
181 this.write(cmd, 0, cmd);
182
183 // write sets stop bit... could be a problem... but does not appear to be
184 Timer.delay(10);
185
186 let result = this.read(responseLength + 3);
187 if (ERROR.NONE !== result[0])
188 throw new Error(result[0]);
189
190 if (result.reduce((a, b) => a ^ b))
191 throw new Error(ERROR.PARITY);
192
193 return result.slice(2, 2 + responseLength);
194 }
195 // offset unimplemented. what does it do? "Time offset in ms"
196 enqueueTxRaw(channel, type, data) {
197 let request = new Uint8Array(10);

Callers 15

getConnectionStatusMethod · 0.95
echobackMethod · 0.95
getUnixTimeMethod · 0.95
getProductIDMethod · 0.95
getUniqueIDMethod · 0.95
getFirmwareVersionMethod · 0.95
getSignalQualityMethod · 0.95
getTxQueueLengthMethod · 0.95
clearTxMethod · 0.95
sendMethod · 0.95
getTxStatusMethod · 0.95
getRxQueueLengthMethod · 0.95

Calls 4

delayMethod · 0.80
writeMethod · 0.65
readMethod · 0.65
sliceMethod · 0.65

Tested by

no test coverage detected