B4R Question libreria AP_Sync_h

roberto64

Active Member
Licensed User
Longtime User
Hi, I don't know c, can someone help me to create a B4R library with this code?
Thanks
Code: Copy
#ifndef AP_Sync_h
#define AP_Sync_h

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

const char valueStart = ':';
const char dataStart = '#';
const char dataEnd = '|';

class AP_Sync{
  public:
    AP_Sync(Stream& s):serial(s){}
    
    template <typename T>
    void sync(T t) {
      serial.print(valueStart);
      serial.print(t);
      serial.print(dataEnd);
      serial.println();
    }
    
    template<typename T, typename... Args>
    void sync(T t, Args... args) // recursive variadic function
    {   
        serial.print(dataStart);
        serial.print(t);
        sync(args...);
    }

  private:
    Stream& serial; 
};

#endif
 
Hi Roberto, maybe you should have posted that in questions sub-forum of B4R.
 
Upvote 0
You can use B4RSerializator, the Serial's stream of B4R and AsyncStreams object which is contained in rRandomAccess library.
 
Upvote 0
Hi hatzisn, thanks for your reply, i'm trying to use processing with B4R for data exchange, trying AsyncStreams with B4R Arduino processing reads the data, but from processing and arduino no.thanks
 
Upvote 0
Back
Top