@RobLauer I’m using Raspberry PI + NBGL.
{"req": "card.version"}
{"body":{"org":"Blues Wireless","product":"Notecard","version":"notecard-3.2.1","ver_major":3,"ver_minor":2,"ver_patch":1,"ver_build":13982,"built":"Feb 3 2022 15:02:36"},"version":"notecard-3.2.1.13982","device":"dev:X","name":"Blues Wireless Notecard","sku":"NOTE-NBGL-500","board":"1.11","api":3}
I’m measuring a consistent 8-12 seconds per 8kByte chunk. The same performance exists using either a RPi+Notecard or a Notecard directly connected to the computer serial port.
In the case of I2C, all of that time is in the _sendPayload which has the unfortunate behavior of sending 255 byte chunks (if max_transfer is left as the default of 0). Each chunk has a minimum time of 0.251 seconds. So with 8192Byte chunks, that’s about 11000Byte base64, which is 43 chunks, which is a total transfer time of 10.8 seconds.
All of the examples I’ve found show OpenI2C being called with max_transfer=0
. I couldn’t find any guidance on what the range of appropriate values are, but if I try to change it to anything greater than 256 it throws an error because reg is a bytearray. The other alternative is to change the CARD_REQUEST_SEGMENT_DELAY_MS to a much lower value, but that would only seem feasible if the Blues team agrees that is a suitable change.
@scjerry TLDR - with the Python library the data rate is being limited by CARD_REQUEST_SEGMENT_DELAY, CARD_REQUEST_SEGMENT_MAX_LEN (SERIAL), and max_transfer (I2C)
@RobLauer are you using the Python library? If not what are you using? I’m curious how you are transferring faster than one-255 byte chunk every 0.25 second.
As for the strange change in behavior (i.e. web.post
returns “total” instead of the expected “result”). I don’t have a good explanation for that yet.
I’ve tried three different notecards (two with RPi and one directly connected to the computer). All of them are using the exact same Notecard firmware and Python code.
The one directly connected to the computer serial is behaving correctly; but both the RPi devices are getting the same unexpected “total” behavior for both fragmented web.post
requests and standard web.post
requests. In fact, I can even specify invalid “route” values and simply get a response of {'total': X}
.
Here are some diagnostics that might help you guide me to a solution:
$ notecard -port /dev/i2c-1 -interface i2c -verbose -explore
{"req":"file.changes"}
{"info":{"_web.dbx":{},"_req.qis":{}}}
_req.qis
{"req":"note.changes","file":"_req.qis","deleted":true}
{}
_web.dbx
{"req":"note.changes","file":"_web.dbx","deleted":true}
{"err":"json: insufficient memory {memory}"}
note.changes: json: insufficient memory {memory}
$ notecard -port /dev/i2c-1 -interface i2c -verbose -req '{"req": "web.post", "route": "SavvyAnalysis", "payload": "SGVsbG8gV29ybGQ=", "total": 11}'
{"req":"web.post","payload":"SGVsbG8gV29ybGQ=","route":"SavvyAnalysis","total":11}
{"total":1}
$ notecard -port /dev/i2c-1 -interface i2c -verbose -req '{"req": "web.post", "route": "SavvyAnalysis", "payload": "SGVsbG8gV29ybGQ="}'
{"req":"web.post","payload":"SGVsbG8gV29ybGQ=","route":"SavvyAnalysis"}
{"total":2}
On a whim I did a card.restore
and that fixed the insufficient memory error. I then
$ notecard -port /dev/i2c-1 -interface i2c -verbose -explore
{"req":"file.changes"}
{}
no notefiles
$ notecard -port /dev/i2c-1 -interface i2c -verbose -req '{"req": "web.post", "route": "SavvyAnalysis", "payload": "SGVsbG8gV29ybGQ="}'
{"req":"web.post","payload":"SGVsbG8gV29ybGQ=","route":"SavvyAnalysis"}
{"total":1}
$ notecard -port /dev/i2c-1 -interface i2c -verbose -explore
{"req":"file.changes"}
{"info":{"_web.dbx":{"total":1},"_req.qis":{}},"total":1}
_req.qis
{"req":"note.changes","file":"_req.qis","deleted":true}
{}
_web.dbx
{"req":"note.changes","file":"_web.dbx","deleted":true}
{"notes":{"UQ129":{"body":{"compress":2,"route":"SavvyAnalysis","method":"POST"},"payload":"CyhIZWxsbyBXb3JsZA==","time":1645909355}},"total":1}
UQ129
{"compress":2,"method":"POST","route":"SavvyAnalysis"}
Payload: 13 bytes
@RobLauer I hope that these logs point to something dumb I’m doing, because otherwise I cannot explain the behavior.