# How to inject a buffer?

**URL:** https://discourse.nodered.org/t/how-to-inject-a-buffer/50503
**Category:** General
**Created:** [1 September 2021 14:02 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503 "2021-09-01T14:02:57Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)
#### Post date: [1 September 2021 14:02 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/1 "2021-09-01T14:02:57Z")

</div>

Hi, I've the I2C node outputting a buffer:

```auto
payload: buffer[2]
0: 0x40
1: 0x0
topic: ""
address: 32
command: 255

```

I need to simulate it from inject, I choose "msg.payload" and buffer, then I type [0x40,0], but doesn't work, I tried also 0x40,0, ([0x40,0]),(["0x40","0"]), but I get always errors. I've tried to figure out reading around but no info on syntax. Thank you.  
PS: would be lovely to include in the brief guide of node, on the sidebar, a quick example for each format

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [1 September 2021 14:36 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/2 "2021-09-01T14:36:29Z")

</div>

`["0x40","0x00"]`

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 September 2021 14:38 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/3 "2021-09-01T14:38:00Z")

</div>

JSON (which is what is entered into the inject node) does not support hex or octal. JSON5 will, but I assume node red is not (yet?) using that. You will have to enter it in decimal `[64,1]`

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 September 2021 16:04 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/4 "2021-09-01T16:04:47Z")

</div>

> [@Steve-Mcl](#):
>
> ["0x40","0x00"]

Oh, I didn't know that. I live and learn. For a while longer at least 🙂

---

<div class="post-metadata">

### Author: ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)
#### Post date: [1 September 2021 16:08 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/5 "2021-09-01T16:08:32Z")

</div>

> [@Steve-Mcl](#):
>
> ["0x40","0x00"]

Thank you, that's the only one I haven't tried 😅

Looking forward for the time NR introduce the chance to change inject without deploy the node 🙂  
I mean not the type, but values yes, really helpful. My flow is really huge and it takes always 3/4 second to deploy it..

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 September 2021 16:12 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/6 "2021-09-01T16:12:20Z")

</div>

If you select Modified Nodes in the Deploy button drop down then if you edit the Inject node only, then only that node will get re-deployed.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [1 September 2021 16:19 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/7 "2021-09-01T16:19:18Z")

</div>

While editing the inject node - you can use the "inject now" button ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/716080e3504799957a71fafe260df3481bd4de73.png)  
to test your input before you finish editing.  
(As part of Node-RED 2.x)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [1 September 2021 16:35 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/8 "2021-09-01T16:35:34Z")

</div>

> [@GiovanniG](#):
>
> My flow is really huge and it takes always 3/4 second to deploy

What deploy type do you do? Full, flow or node?

---

<div class="post-metadata">

### Author: ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)
#### Post date: [1 September 2021 17:51 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/9 "2021-09-01T17:51:27Z")

</div>

thank you, really useful answers! I got now on partial Deploy, which speeds up dubug process (before I was just deploy, as I always did, poor servers that had to re register my nodes again and again), and about NR 2! I've read you introduced lot of staff, but I'll wait for next time to install a version that have been super-tested )

About that I have an important suggestions, which is about debug problems, I thin it's really useful:

1. On an error message (from function for example), to put more evidence to which function generated it. Now you just slighly border the function, which result invisible on a fully zoomed out flow. My flow is really big and when it happened, I just couldn't find it (was not an hidden module). Suggest to change its color fully, maybe flashing it.
2. When a debug is outputting a message, it's also very useful to understand who generated it. If a message contain an error, that made the function stop, we haven't details (such as message object) to understand where it come from, for example: something like "can't read property topic of undefined", if I remember right it comes to debug because it's linked to the function, if you click on it the debug node flashesh.. not the function which generated it.  
Thank you

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 September 2021 07:09 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/10 "2021-09-02T07:09:41Z")

</div>

> [@GiovanniG](#):
>
> My flow is really big

Maybe it would be a good idea to split up the tab into multiple tabs. I try to make sure that a flow fits onto a single screen without zooming (or nearly fits at least).

> [@GiovanniG](#):
>
> we haven't details (such as message object) to understand where it come from

Set the debug node to Output Complete Message and you can see the full message object.

> [@GiovanniG](#):
>
> if I remember right it comes to debug because it's linked to the function, if you click on it the debug node flashesh.. not the function which generated it.

Once you see which debug node it is, then you just have to follow the wire back to see the function.

---

<div class="post-metadata">

### Author: ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)
#### Post date: [2 September 2021 08:53 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/11 "2021-09-02T08:53:34Z")

</div>

Hi, sorry but your suggestions sounds all not practicable for me

- I need all in a flow, to avoid adding extra nodes to link on different flows, for me is comfortable like that. Anyway I have so many nodes that I would need at least 20 different flows, and browse between tabs to find them sounds bad for me, sorry
- You didn't catch me, I'm not telling you I can't see full message, I'm telling debug node doesn't tell me from which function is coming from that message. You are suggesting me to add debug node as many as functions I need to debug. Yes it can be a way, just sounds a bit weird. Usually when I debug I put a debug node close, then I link on it all nodes I need to monitor, nad not an each debug node for each link..  
I hope I expleined myself correctly )

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [2 September 2021 09:00 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/12 "2021-09-02T09:00:35Z")

</div>

> [@GiovanniG](#):
>
> I'm telling debug node doesn't tell me from which function is coming from that message. You are suggesting me to add debug node as many as functions I need to debug. Yes it can be a way, just sounds a bit weird. Usually when I debug I put a debug node close, then I link on it all nodes I need to monitor, nad not an each debug node for each link..

The correct way to see where a msg came from is to have only ONE wire into a debug. That way, there is zero doubt where it came from.

Alternatively, in each function, add something into the msg to identify it.

> [@GiovanniG](#):
>
> Anyway I have so many nodes that I would need at least 20 different flows, and browse between tabs to find them sounds bad for me

Do you know the link nodes have a clickable hyperlink that jumps you to the relevant tab?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 September 2021 09:12 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/13 "2021-09-02T09:12:24Z")

</div>

> [@GiovanniG](#):
>
> avoid adding extra nodes to link on different flows

Why do you want to avoid links?

It is very unusual for a flow not to naturally break up into blocks fulfilling specific purposes. Inputs, Outputs, Logic for each section of the requirement, and so on. For example one of mine has tabs labelled Temperatures, Controls, Schedule, Conservatory, Kitchen and so on.

> [@GiovanniG](#):
>
> I would need at least 20 different flows

The central server controlling my home has 35. It is not a problem. The `i` tab shows them all as a list and you can jump to any of them by hovering and clicking the search button that pops up.

> [@GiovanniG](#):
>
> You are suggesting me to add debug node as many as functions I need to debug.

Yes, generally one is only debugging one function at a time. When you have more than one Debug node on the flow at a time make sure you give them names so the output is easily identifiable.

---

<div class="post-metadata">

### Author: ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)
#### Post date: [2 September 2021 11:28 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/14 "2021-09-02T11:28:36Z")

</div>

Mates, I'm not arguing with you about something, thank you for your kind explanations 🙂 for sure I'm not using it in the proper way. I've just thought it was useful to see in the debug node where the message come from, maybe not complicated to implement, useful.

By the way, I think you agree about the general function error (not coming from debug node), kindly to make it more evident the flashing, to find it when zoom is out. Thank you

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [2 September 2021 12:00 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/15 "2021-09-02T12:00:16Z")

</div>

> [@GiovanniG](#):
>
> maybe not complicated to implement

Actually very complicated to implement as the input event only has the knowledge of the msg contents, and the knowledge of what is wired to what is only held by the preceeding node. The simplest way is as Colin suggests to add another property to the messages so you can tell them apart, or use separate debug nodes.

> [@GiovanniG](#):
>
> make it more evident the flashing, to find it when zoom is out

useful thought - noted.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [16 September 2021 12:01 UTC](https://discourse.nodered.org/t/how-to-inject-a-buffer/50503/16 "2021-09-16T12:01:16Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
