String to response code

Hi All,
I am working on a bit of a side project where I am trying to monitor the status of a radio, with the final goal of using it to log signal level against GPS location. The uses a proprietary serial protocol that sends and receives messages as basic text. The format of this is generally [ID][Size][Parameters][checksum] where ID is a single ASCII character to categorize the message, Size is the number of characters in the parameters field and is expressed in ASCII hex notation (2 characters), The parameters field is optional and depends on the type of message, checksum is 8 bit checksum of the ID, Size & Parameters fields.
I am thinking that i will need to detect the first character (ID) and then have some function to break up the remaining text and create an output message.
some examples of message id's are: e = error, p=progress report, v=version numbers, etc.
for instance, if i receive p0205C9 it is a progress report, 2 characters in the parameters field, 05 = receiver busy.
I am not sure how the best way is to split these messages up so that i can match it with the list of different functions/parameters.
Are there specific nodes that would be suited or should i do it all in a single function node? I am a complete novice with writing functions but can generally learn quickly from examples.

Any help would be greatly appreciated

You can use buffer parser to extract the first character then route the message (using a switch node) to another appropriately set up buffer parser for that particular ID to parse out the remaining elements.

Search the forum for "buffer parser" & you will see write a few examples. Also, read the readme & built in help.

Give it a go, see where you get to.

If you don't succeed, post several examples of data & annotate then with what they should be parsed to & I'll show you how.

Thanks for the feedback, i will see how i go and let you know

The buffer parser looks like it would be ideal for this.
I am having some issues in getting data out.

I have made a simple demo with a copy of the data string in an inject node.
It looks like the payload is empty

[{"id":"b235016f1d0add12","type":"buffer-parser","z":"687fd45598d0e446","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"string","name":"ID","offset":0,"length":2,"offsetbit":0,"scale":"1","mask":""},{"type":"string","name":"Size","offset":2,"length":2,"offsetbit":0,"scale":"1","mask":""},{"type":"string","name":"Data","offset":4,"length":6,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":true,"fanOutMultipleResult":false,"setTopic":false,"outputs":1,"x":870,"y":340,"wires":[["99e8056ff941dba4"]]},{"id":"99e8056ff941dba4","type":"debug","z":"687fd45598d0e446","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1110,"y":340,"wires":[]},{"id":"fe3d112337a2d0f1","type":"inject","z":"687fd45598d0e446","name":"Eg Data","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"..m0853103.069B","payloadType":"str","x":540,"y":340,"wires":[["b235016f1d0add12"]]}]

Where are the example data strings and the descriptions to help me break them down for you?

The flow you posted above seems to have spurious ``` characters at the end, causing an error when I try and import it.

In the first post you gave an example of the data p0205C9 but in the flow you inject ..m0853103.069B.

Im am not sure why there is an issue importing the flow, I reimported from the above post without any issues.
The 2 separate examples follow the pattern [ID][Size][Parameters][checksum]:
ID=progress report message
Size=02 Characters in Parameters field
Parameters=05=Receiver busy

. are received when message is in response to command
Size=08 Characters in Parameters field
Parameters=53103.06=P25 Digital Mobile Phase 2-capable,TM9400(531), v3.06 software (3.06)

I have managed to get this working using a combination of a switch node and function nodes. For some reasonI just could not get the buffer parser node to work. The switch node is looking for an occurrence of one of the ID's, ie .p or .m, .j, etc. each of the different ID's is switched to its own output and fed into a function node. In the function node I am using indexOf to locate the ID (some strings have a single . preceding the ID letter and some have multiple) I am then using substr to break down the string into its components.

Here is an example of one of the function nodes

var ID = msg.payload.indexOf(".j")
var size = msg.payload.substr(ID+2,2)
var cctmcmd = msg.payload.substr(ID+4,3)
if (cctmcmd=="064") {
    var rssi=Number(msg.payload.substr(ID+7,size-3)/10)

return msg;