Parsing Hex by bytes?

So I have a device that sends me values as hex. It sends it over in 18byte lengths. however it sends it over in a format i need to convert. The first 2 bytes are ok, but the following bytes need to be swapped. How do i get each byte separated and correctly swapped? I'm used to using actual PLC's so having a limited set of instructions is throwing me.

Screenshot 2025-05-21 173008

Do you have sample data streams we can play with?

The data structure is vague, with contradictions.

Are negative numbers expected?

Should every packet be exactly 2 + (3 * 2) = 8 bytes long, because you are receiving 3 values in each packet?

Or should it be 2 + (3 * 3 * 2) = 20 bytes long?

Here's my take on the data collection, relying on the BlueTooth component to parse integers as they arrive, under your prescribed byte order, expecting exactly 9 ints per packet, and ignoring other packet types.
BlueTooth_bytes.aia (3.8 KB)

Of course, I can't test this.

I also left out any permission seeking.

P.S. If I guessed wrong about the two-byte numbers being signed, there is also a ReceivedUnsigned2ByteNumber block you can try instead.

Every packet will have the same first 2 bytes. Each byte thereafter will be the Lower byte vale then upper byte value of different sensor points. The values are signed I believe. I am really only interested in the value of the first 6 points (XYZ Acceleration) as I'm trying to figure out when it detects hitting something. I suppose I could use the velocity change too but for now If I could just get the data arranged correctly it would help. I was trying to figure out how to move each byte into a separate variable then use them in order of how i need them but it seems to take all the data in at once rather than just byte by byte. (Thats how i thought bytes received worked.

the data being sent is below along with a bit more of the packet data.
Screenshot 2025-05-21 205203

here is the actual values it is sending in proper form, Well the acceleration data anyway
Screenshot 2025-05-21 204828

image
Screenshot 2025-05-21 203924
Screenshot 2025-05-21 203953
Screenshot 2025-05-21 204019

And Thank you It seems most of the information I have found and been using for this so far is all either directly from one of your posts or somehow related to one! You are a AppInventor wizard!

If you see reasonable looking 9 item lists appearing in the data collection List View, then all you need is to apply Select Item from List blocks to map the intList into your Labels.

P.S. From your description, I would expect to find acceleration X,Y,Z in items 1,2,3 of int_list.

I don't know about your |a|. Are you taking the diagonal, or just the max of the absolute values of X,Y,Z?

Here's a Canned Reply for the list extraxtion and Label population part.

It is from a text based approach, so just stick to the little loop over the list of Label components, and avoid the text reception and processing parts.

Here is an updated blocks sample illustrating these ideas ...

BlueTooth_delimiter_sample.aia(3.4 KB) global message

...

Thank you for the quick response. I will look this over and see if it makes sense to me and give it a shot. This bit banging stuff sure is easier in a PLC! but hey if it were easy everyone would do it i suppose.

I assume you know g
is 9.80665 and can do math in AI2?