Teensy 3.1 Serial Sync?

Status
Not open for further replies.

Mark

Well-known member
Again, for 2.0 this works fine. Sending the sync string (~FF0000000000000) doesn't get a response back of 'sync'. I'm thinking the LIFA and LabVIEW code is ok, but I'm at a loss where to proceed into the Teensy 3 libs.

I'll simplify further a vi for the test case (later today, I hope), but thought I'd bring it up now just in case it's a "Oh!" moment...

Here's where it seems to break in the LabVIEWInterface.ino code. ~Line 114.

Code:
// Processes a given command
void processCommand(unsigned char command[])
{  
  // Determine Command
  if(command[0] == 0xFF && checksum_Test(command) == 0)
  {
    switch(command[1])
    {    
    /*********************************************************************************
    ** LIFA Maintenance Commands
    *********************************************************************************/
    case 0x00:     // Sync Packet
      Serial.print("sync");
      Serial.flush();        
      break;
    case 0x01:    // Flush Serial Buffer  
      Serial.flush();
      break;

Regards, Mark
 
Maybe connect a USB-serial converter (or another Teensy running File > Examples > Teensy > USB_Serial > USBtoSerial) to the Serial1 pins, and add some code to transmit every byte that comes in to Serial1. Then watch with another computer, or even your same computer running a program like CoolTerm, to see what data is actually coming through...

Maybe the command[] array isn't getting filled? Or maybe it is, and checksum_Test() is failing? Or maybe something else is wrong.

As with most technical problems, when you're stuck, the path to get unstuck usually involves adding more ways so you can observe what's really going on.... until you get info that makes the true nature of the problem apparent.
 
Maybe connect a USB-serial converter (or another Teensy running File > Examples > Teensy > USB_Serial > USBtoSerial) to the Serial1 pins, and add some code to transmit every byte that comes in to Serial1. Then watch with another computer, or even your same computer running a program like CoolTerm, to see what data is actually coming through...

Maybe the command[] array isn't getting filled? Or maybe it is, and checksum_Test() is failing? Or maybe something else is wrong.

As with most technical problems, when you're stuck, the path to get unstuck usually involves adding more ways so you can observe what's really going on.... until you get info that makes the true nature of the problem apparent.

I'll poke around a bit on the hardware side, just to see what's getting thru. I'll try your 'softer' suggestions too.
 
Been busy with other stuff... Back now for awhile (hopefully).

Running 2 USB-RS232 adapters and a null modem cable, I'm able to confirm the data is getting through to the serial port ok. The data transmitted from LabView is received at the receiving port (Cool Term - nice BTW) as "00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 FF", which is correct. I don't see why it wouldn't parse the data in the 3.1 the same as the 2.0.

Off to dig some more... Still haven't isolated if it's something in the LIFA code or the 3.x libs. Since the only change is 2.0 to 3.1, I'm suspecting the 3.x libs, but still could be a problem in the LIFA firmware code.
 
Don't know why it makes a difference for Teensy 3, and not Teensy 2, but correcting <?> a declaration in LabVIEWInterface.ino:

unsigned char checksum;

to

unsigned char checksum = 0;

seems to have fixed LIFA's sync function. Why it makes a difference for T3 and not T2 or Arduino? <shrug> I'm gonna test it some more, e.g. run the code on Teensy 2 and an Uno, then post on the LIFA forum to see what they say. I've got a good feeling this fixes this bug tho'. Another layer of the onion peeled. <fingers crossed> I'll be back...
 
Status
Not open for further replies.
Back
Top