Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
Javascript / Nodered function node: bitstream operations

Following task to do:

There is a protocol that defines minimalistic data like:

binary     0 1 0 0 0 1 1 1 0 0 1 1 1 0
variable   [-] [-----] [---] [-------]
name       a      b      c       d

where parameter "a" consists of 2 bits, parameter "b" of 5 bits and so on. I have to set them like

a=1
b=1
c=6
d=...

so the above bit buffer will automatically result.

This stream of bits shall be stored in a buffer like this:

let buf = Buffer.alloc(64, 0);

Is there a possibility to achive this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There are a number of approaches to this.

  1. Using nodes like the node-red-contrib-buffer-parser which will allow you to do this as part of a flow

  2. Do basic bit shifting in function nodes. e.g.

    var a = 1
    var b = 16
    var c = 2
    var d = 10
    
    var answer  = a << 14 | b << 12 | c << 10 | d << 6
    

    which can then be written to a buffer.writeUint16()

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda