Get value from serial string

Hi,

I receive an serial string from a device locking like the following one. The “105” could be different every time the command is received.

NOTIFY set MTX:mem_512/60000/0/0/0/0/0 0 0 105 “1.05”

I want to assign the “105” to a vriable and send them as value via MIDI. Ca someone help me to find a solution?

Thank you and greetings

Jan

Hi and welcome to the Bome community!

The attached file shows how you can do this and is using it using a simple serial loopback.
The first translator sends the message to COM1 when you push a MIDI note 0 on my controller.
The second translator is what you are looking for. It looks at the incoming message and when it sees “1.05” it will capture the digits. I use this message since it is easier to delimit the pattern that includes the quote marks.

1 become local variable “oo”, 0 becomes the local variable “pp” and 5 becomes the local variable “qq”

Then in rules I subtract 0x30 to get the decimal value for each variable (which is sent as ASCII coding).

For oo, I then multiply times 100
For pp, I multiply by 10

Then I add the values together to get the final value of rr (105).

I have logging on in rules so you can see in the log window the result.

Here are the rules:

Log "Message Received oo=%oo% pp=%pp% qq=%qq%"

oo=oo-0x30
oo=oo*100
pp=pp-0x30
pp=pp*10
qq=qq-0x30

rr=oo+pp
rr=rr+qq

Log "Final Number is %rr%"

And the results:

1: IN   0.0  Note On on ch. 1 with note:0 (0x00) and velocity:127 (0x7F)
2: OUT  0.0  wrote set MTX:mem_512/60000/0/0/0/0/0 0 0 105 “1.05” to COM1 [Serial]
3: IN   0.1  Serial Port: 73 65 74 20 4D 54 58 3A 6D 65 6D 5F 35 31 32 2F 36 30 30 30... from COM2 [Serial2],  oo=0x31 pp=0x30 qq=0x35
4: 0.1:2 Message Received oo=49 pp=48 qq=53
5: 0.1:13 Final Number is 105

Serial ports are set up with aliases as follows.

image

I’m using a comOcom virtual serial loopback pair for testing.
image

Finally the project file I used.
Serial-Loop-Detect-Test-2023-01-27.bmtp (1.6 KB)

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Thank you for your fast reply. I understood your example but the next problem is that the important positions are changing.
Here is an example of a full set ob messages:

NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 0 “-INFINITY”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 3 “-93.00”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 7 “-74.00”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 9 “-70.60”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 18 “-57.20”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 19 “-55.80”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 26 “-44.20”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 28 “-41.40”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 31 “-37.90”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 33 “-36.40”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 36 “-33.60”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 41 “-30.00”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 45 “-27.10”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 46 “-25.70”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 51 “-22.10”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 53 “-20.00”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 61 “-17.15”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 75 “-11.45”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 83 “-8.20”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 88 “-6.05”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 97 “-2.50”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 107 “1.45”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 111 “2.85”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 112 “3.55”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 120 “6.45”
NOTIFY setn MTX:mem_512/60000/0/0/0/0/0 0 0 128 “10.00”

I want to send the 0-127 to an Midi Fader board. hopefully you could help me again. Thank you.

Jan

Maybe i got it by my own, what do you think?

Log "Message Received oo=%oo% pp=%pp% qq=%qq%"

if qq==32 then Goto "Two"
if pp==32 then Goto "One"
if qq!=0 then Goto "Three"

//two digit
Label "Two" 
oo=oo-48
oo=oo*10
pp=pp-48
rr=oo+pp
Log "ONE: Final Number is %rr%"
exit rules, execute Outgoing Action

//three digit
Label "Three"
oo=oo-48
oo=oo*100
pp=pp-48
pp=pp*10
qq=qq-48

rr=oo+pp
rr=rr+qq
Log "Two: Final Number is %rr%"
exit rules, execute Outgoing Action

//one digit
Label "One"
rr=oo-48

Log "THREE: Final Number is %rr%"

Yes something like that should do it. However I’m thinking with a loopback on the same device which I have it gets a little honky with the timing of the messages. You may just want to configure the receive portion.

I’ve configured it to read the 3 digits before the quotes, so less conversion is needed.

Serial-Loop-Detect-Test-2023-01-28.bmtp (3.5 KB)

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz