I have some code like the below, where I receive bytes one by one, and place them into a blob (I couldn’t make strings work, and another thread here seems to suggest blobs is the way to go).
Now I’d like to output the received bytes as part of a formatted string, but I constantly get the error “ERROR: string expected for the specified format” (or similar if I use other variable qualifiers).
I understand the error as %s means a string, and a blob is not a string, which I fully agree on. But I haven’t been able to locate any info about now to perform the conversion from blob to string, so I can use it with the format function.
`
local PNM = blob(6);
PNM[0] = spi.receive();
PNM[1] = spi.receive();
PNM[2] = spi.receive();
PNM[3] = spi.receive();
PNM[4] = spi.receive();
PNM[5] = 0;
hardware.uart1289.write(PNM); // 5 x 8 bit ASCII - this works.
hardware.uart1289.write(format(" Product Name: %s",PNM)); // 5 x 8 bit ASCII - this produces the error.
`
I’m looking forward for your response.