Hi all,
I have a project where I am using the teensy 4.1 to act as a bridge between ethernet data and usb data.
I am struggling to find the cause of data corruption in the data path.
I have a file that I can successfully transfer from pc to an FTDI device via usb. No corruption
I then send the same data via telnet connection to Teensy 4.1 and then send that via usb host to the FTDI device. I get data corruption.
The FTDI device returns a checksum when it receives the file. The checksum values are different between using the USB directly from the pc, or when using the pc -> teensy -> FTDI module.
I have tried to slow the rate down and the resulting checksum is still different.
I use teraterm to send the file direct to the FTDI module. = no corruption
The file is 4096 bytes in length.
This is the function I have written that sends the file to the FTDI module:
#include "USBHost_t36.h"
#include <SPI.h>
#include <EEPROM.h>
#include <QNEthernet.h>
namespace qn = qindesign::network;
void UploadMode() {
// Wait for data from C# app
Serial.println();
client.println();
while (client.available() < FILE_SIZE) {
delay(100);
}
// Read the entire file into a buffer
uint8_t buffer[4096];
client.readBytes(buffer, FILE_SIZE);
Serial.println("File Received");
client.println("File Received");
// Send the buffer to the Danville Audio module
//uSerial.write(buffer, sizeof(buffer));
for (int i = 0; i < 4096; i++) {
uSerial.write(buffer);
delayMicroseconds(100);
//Serial.println(buffer);
}
Serial.println("File Uploaded");
client.println("File Uploaded");
uploadModeFlag = false;
}
All other aspects of my teensy code work very well. Its only the file transfer issue that I am stuck on.
Any assistance would be greatly appreciated. I've exhausted all my knowledge trying to solve this issue.
Damien
I have a project where I am using the teensy 4.1 to act as a bridge between ethernet data and usb data.
I am struggling to find the cause of data corruption in the data path.
I have a file that I can successfully transfer from pc to an FTDI device via usb. No corruption
I then send the same data via telnet connection to Teensy 4.1 and then send that via usb host to the FTDI device. I get data corruption.
The FTDI device returns a checksum when it receives the file. The checksum values are different between using the USB directly from the pc, or when using the pc -> teensy -> FTDI module.
I have tried to slow the rate down and the resulting checksum is still different.
I use teraterm to send the file direct to the FTDI module. = no corruption
The file is 4096 bytes in length.
This is the function I have written that sends the file to the FTDI module:
#include "USBHost_t36.h"
#include <SPI.h>
#include <EEPROM.h>
#include <QNEthernet.h>
namespace qn = qindesign::network;
void UploadMode() {
// Wait for data from C# app
Serial.println();
client.println();
while (client.available() < FILE_SIZE) {
delay(100);
}
// Read the entire file into a buffer
uint8_t buffer[4096];
client.readBytes(buffer, FILE_SIZE);
Serial.println("File Received");
client.println("File Received");
// Send the buffer to the Danville Audio module
//uSerial.write(buffer, sizeof(buffer));
for (int i = 0; i < 4096; i++) {
uSerial.write(buffer);
delayMicroseconds(100);
//Serial.println(buffer);
}
Serial.println("File Uploaded");
client.println("File Uploaded");
uploadModeFlag = false;
}
All other aspects of my teensy code work very well. Its only the file transfer issue that I am stuck on.
Any assistance would be greatly appreciated. I've exhausted all my knowledge trying to solve this issue.
Damien