I'm using a Teensy 4.1 with USBHost_t36 to control an 8-relay USB box, specifically a KMTronic box. It works great! So I bought another one.
Unbeknown to me the first KMTronic uses CDC, whereas the second one I bought uses FTDI and doesn't work.
I've spent days and days on this and it feels like I'm close to getting it working as I can see that the Teensy recognises the device and claims it, and my code is obviously sending something to the KMTronic as its comms lights flash, but it's just not working.
By way of some info, if I plug the KMTronic in to a Linux box it assigns it /dev/ttyUSB0 and so the following works just fine:
- Relay 3 ON
echo -e "\xFF\x03\x01" > /dev/ttyUSB0
- Relay 3 OFF (works)
echo -e "\xFF\x03\x00" > /dev/ttyUSB0
But this code on the Teensy, whilst clearly sending *something* to the KMTronic, fails to control it.
Help!
Unbeknown to me the first KMTronic uses CDC, whereas the second one I bought uses FTDI and doesn't work.
I've spent days and days on this and it feels like I'm close to getting it working as I can see that the Teensy recognises the device and claims it, and my code is obviously sending something to the KMTronic as its comms lights flash, but it's just not working.
By way of some info, if I plug the KMTronic in to a Linux box it assigns it /dev/ttyUSB0 and so the following works just fine:
- Relay 3 ON
echo -e "\xFF\x03\x01" > /dev/ttyUSB0
- Relay 3 OFF (works)
echo -e "\xFF\x03\x00" > /dev/ttyUSB0
But this code on the Teensy, whilst clearly sending *something* to the KMTronic, fails to control it.
Help!
C++:
#include "USBHost_t36.h"
#define USBBAUD 9600
USBHost myusb;
USBSerial_BigBuffer userial(myusb, 1);
byte rCmd[] = {255, 3, 1};
void setup() {
myusb.begin();
userial.begin(USBBAUD, USBHOST_SERIAL_8N1);
}
void loop() {
myusb.Task();
if (userial) {
// Relay 3 ON
rCmd[1] = 3;
rCmd[2] = 1;
userial.write(rCmd, 3);
delay(1000);
// Relay 3 OFF
rCmd[1] = 3;
rCmd[2] = 0;
userial.write(rCmd, 3);
delay(1000);
}
}