Page 1 of 1

SendData hex number

Posted: Sun Nov 09, 2025 6:53 pm
by Paski
I’ve got a reproducible glitch: without a timestamp the value is fine, add a timestamp and the Y value shows up as a hex.

// OK → numeric shown correctly (e.g., 25)
gT1.SendData("temp1", (float)t1_C);

// NOT OK → arrives as hex
gT1.SendData("temp1", ts.c_str(), (float)t1_C);

Targeting this per docs:
SendData(SeriesName, TimeStamp, YValue, SeriesProperties — optional)


Environment

Teensy 4.1

ts is a std::string (ASCII, no NULs), lifetime valid

Series name is a RAM string (no F() macro)

Tried

Explicit casts:

gT1.SendData("temp1", ts.c_str(), static_cast<float>(t1_C));
gT1.SendData("temp1", ts.c_str(), static_cast<double>(t1_C));


Ask

For the timestamped call, does YValue need to be a specific type?

Is there an overload-resolution trap where (const char*, float) binds to a variant that treats the float as raw bytes?

What timestamp format does this overload expect (epoch ms, ISO-8601, etc.) to keep YValue parsed as numeric?

What’s the exact prototype I should be hitting for (SeriesName, TimeStamp, YValue)?



Thanks for your help!

Re: SendData hex number

Posted: Wed Nov 12, 2025 9:47 am
by admin
Hi Oriol,

I haven't had a chance to reproduce yet, but my guess is the compiler is matching this overload:

Code: Select all

  template<typename TSeries, typename TYData>
  void SendData(TSeries seriesName, TYData yValue, const RGBColor& Color, LineStyle Line = MissingLineStyle, uint8_t uLineWidth = 0, MarkerStyle Marker = MissingMarkerStyle, Axis ax = MissingAxis)
  {
    SendSeriesHeader_Data(seriesName, false);
    SendDataCore(nullptr, nullptr, yValue, Red, Color, true, Line, uLineWidth, Marker, ax);
  }
In otherwords, it is treating the time string as the YData and construct an RGB colour from your float / double argument. Colours are sent in hex, hence the result you see. I should have marked the `RGBColor(uint32_t)` constructor as explicit so this didn't happen. Sorry.

A couple of suggestions:
* use one of the SendData overloads that use the tm structure (https://en.cppreference.com/w/c/chrono/tm) as an argument, if you have time in this format,
* build the message manually, as you already demonstrate successfully. MegunoLink will accept dates as a double or integer (treated as seconds since the Unix time epoch) or in these formats:

Code: Select all

private static readonly string[] m_astrDateTimeFormats = new string[]
      {
        "yyyy-M-d H:m:s",
        "yyyy-M-d H:m",
        "yyyy-M-d H:m:s.FFFF",
        "yyyy-M-d",
        "H:m:s",
        "H:m",
        "H:m:s.FFFF"
      };
Kind regards
Paul.