Regarding obtaining a number

Hello All,

I am new to Node red and my skills at coding are really low. lol
However, I am working with a software from where i am scanning a bar code using a tool and I am trying to send the data to node red using a link and establishing a connection with the device. On the dashboard i am being able to see the data in string format. What i want to do is just be able to obtain the number from the string.

This is the flow. At this stage it is disconnected.

Change the debug node to display the 'Complete msg object' and add a second on to the output of the TCP node. Run it and show us what is coming out

Ok, (oh, I see someone else is replying, but here goes @zenofmud and his reply beat mine in being posted)

Post what you see from the debug node.

That would help.


The number 00384290470000000010 is what i just need to obtain and display using the output node. I am basically trying to write a function where i will just obtain that number which my barcode scanner is reading

Ok, see the little triangle just to the left of the payload in the output?

Click it and that will expand what is there to even better readability.

Oh, and do as Paul (@zenofmud) suggested: Put a debug node on the output of the tcp node also. And make it also show the entire message.

okay doing

You just missed where I meant.

Try this one:


i added another debug node to the output of the tcp. However, now my debug node shows nothing. This picture above is before i cleared my debug

What options do you have set in ther TCP in node?

Both nodes are turned "off". Click on the buttons at the right (which are now kind of empty boxes) and they will become filled green boxes.

hahaha im sorry for making such silly mistakes
Anyway,

Ok, so you are sending in a stream of strings - why are you using a json node?

Ok, now to get down to business.

Rather than posting screen shots.......

Move the mouse over the payload line in the right part of the screen. (Where the purple word payload is...... Go to the right more and there are three icons.
One is like a >_ looking thing. The next is ..... Keep going to the one which looks like a clip board.

When you put the mouse on/over it, it will pop up something like "copy to clip board".
Click there and then in the area you type your reply enter what is there.

But while you are doing this format it:

Press the key which is top left of the keyboard. Paste the value. Press the key again and it will make it look nicer on the screen.
I had to enter doubles here because of formatting rules.
(Ok, that didn't work either. Sorry.)

I mean when i used buffer in the tcp or string 64, the number didnt seem to appear. SO in the tcp i changed the output to string format. Well, i was just trying to understand which function node shouyld i use, the json or the function node only

So you have a msg.payload that is a big string - which number from it are you tryng to get?

I kind of admire you "go get it" way of thinking. But please understand by just randomly adding nodes, you are only going to confuse yourself faster than if you understand what is the raw data coming out of the node in the first place.

The number 0038429047000000010 is what i am trying to obtain only.

So this: 0038429047000000010 is the bar code - yes?

Delete the json node and the debug node connected to it.

Just have the tcp and the debug connected to it.
Set the debug to complete msg object, get that, click on the triangle as I said earlier and then copy the entire payload as I also explained and we can go from there.

What does the payload look like if you set the TCP node to display 'Base 64 string'?