Awesome.
I played around a bit, but it was really easy. Totally unexpected, everything works absolutely fine.
I still use the circuit as written in my previous post. Then adapted the SerialPortHandler as you suggested.
Code:
const uint8_t DXL_DIR_PIN = -1; // Do not use dir pin
class NewSerialPortHandler : public DYNAMIXEL::SerialPortHandler
{
public:
NewSerialPortHandler(HardwareSerial& port, const int dir_pin = -1)
: SerialPortHandler(port, dir_pin), port_(port), dir_pin_(dir_pin)
{}
virtual size_t write(uint8_t c) override
{
size_t ret = 0;
ret = port_.write(c);
port_.flush();
return ret;
}
virtual size_t write(uint8_t *buf, size_t len) override
{
size_t ret = 0;
ret = port_.write(buf, len);
port_.flush();
return ret;
}
private:
HardwareSerial& port_;
const int dir_pin_;
};
Tested it with a XL320 and a 2XL430. And of course, you were right. When I said I didn´t use any other boards I forgot to mention that I in fact use a level shifter to shift the 5V to 3.3V, so Teensy doesn´t take damage. The circuit mentioned is on the 3.3V side of the data line.
So thank you very much KurtE!! Made my life a lot easier