Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Control lenght of payload with S_INFO

Control lenght of payload with S_INFO

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 2 Posters 839 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • wimdW Offline
    wimdW Offline
    wimd
    wrote on last edited by
    #1

    Hi,

    I have :

    // define my payload
    char payload[8] = "12345678";
    // define my myssage
    MyMessage nikoBusMessage(0, V_TEXT);
    // and sending the message in the program
    send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload));
    
    

    But when the message is send, a complete payload of 26 char is send.
    How do I control the lenght of the payload that I want to send?

    I tried :

    send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload,8));
    

    but then the asci value for each character of "12345678" is send in the payload.

    mfalkviddM 1 Reply Last reply
    0
    • wimdW wimd

      Hi,

      I have :

      // define my payload
      char payload[8] = "12345678";
      // define my myssage
      MyMessage nikoBusMessage(0, V_TEXT);
      // and sending the message in the program
      send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload));
      
      

      But when the message is send, a complete payload of 26 char is send.
      How do I control the lenght of the payload that I want to send?

      I tried :

      send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload,8));
      

      but then the asci value for each character of "12345678" is send in the payload.

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      @wimd the second option looks correct to me. Did you expect something else than the ascii characters to be sent? If so, what did you expect?

      I think the first option can work if you end the string with a null character (\0)

      1 Reply Last reply
      0
      • wimdW Offline
        wimdW Offline
        wimd
        wrote on last edited by
        #3

        When i limit the lenght with

        send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload,8));
        

        I get this as output (ascci values of char) :
        0;54;1;0;47;3132333435363738
        Maybe a bug in library?

        But indeed the solution with the nul character works fine.

        Than

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        16

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular