Inconsistent rsp when following the RPI tutorial

Hello all,

This is my first delve into the Blues, and very new to programming in general.

I’m following this tutorial, and I’ve made it down to step 7 of “Write Code”. I I have tried changing the port address from 0 to 0x17 per some google searching, without change.
Here is my code:

# This script is used to test the functionality of a Blues Notecard
import json
import notecard
import notecard_pseudo_sensor
from periphery import I2C
import time

#Taken from bluesnotehub under devices>summary
productUID = "com.xxx.xxx:dev_project"

port = I2C("/dev/i2c-1")
card = notecard.OpenI2C(port, 0x17, 0)
#card = notecard.OpenI2C(port, 0, 0)

#Configure the Notecard:-------------------------
req = {"req": "hub.set"} 
req["product"] = productUID
req["mode"] = "continuous"

print(json.dumps(req))

rsp = card.Transaction(req)
print(rsp)
#--------------------------------------------

And the response is:

{"req": "hub.set", "product": "com.xxx.xxx:dev_project", "mode": "continuous"}
{'crc': '0000:A3A6BF43'}

Per the tutorial, I should receive an empty {} indicating a successful request.
What does {‘crc’: ‘0000:A3A6BF43’} indicate?

If I continue through the tutorial, I can create mock sensor readings, send them to Notehub rsp={‘total’: 1, ‘crc’: ‘0001:15CB2833’} where they are visible in the Events tab.

Since the tutorial states I should receive an empty JSON object if successful (my rsp is not empty), but the data is sent successfully (also without an empty JSON rsp), am I getting an error or is the documentation outdated?

Hi @smoser

Welcome to the Blues forums!

You’re on the right track, there are a couple of things you’ve covered that actually need better documentation / updating on our side.

  1. Using card = notecard.OpenI2C(port, 0, 0) is valid as internally this calls the default I2C address of the Notecard (0x17). Are you unable to use the OpenI2C() function with the default parameters?

  2. The tutorial was likely written before we introduced the CRC feature. CRCs, as you are seeing, are in fact a sign of a successful request, and we use them to verify the integrity of the transmitted payload. They are enabled by default for requests made from the note-python library. If you’re interested in seeing where this feature comes from in the note-python library, you can find it here.

Hopefully that helps provide some clarity around what you are seeing.

Thanks,
Alex

Thank you Alex for the speedy response. While I don’t know how to use the OpenI2C() function yet, I can send and request information using the Notecard.

Concerning CRC responses, thank you for confirming what I had suspected!

1 Like