Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Serial communication with U6

  • Please log in to reply
5 replies to this topic

#1 lucia

  • Members
  • 3 posts

Posted 31 May 2013 - 04:01 AM


I need to communicate via asynchronous serial communication from a U6 to an LCD display controller.

I am using Linux and the following is the code I am using to configure the UART:

int Form1::asynchConfig()

int sendChars, recChars;
typedef void *HANDLE;
HANDLE hDevAsync;

if( (hDevAsync = openUSBConnection(-1)) == NULL ){
printf("No U6");
return -1;

//Initializing sending and receiving buffers
uint8 sendAs[10];
uint8 recAs[10];
for(int i=0; i<10; i++)

sendAs[1] = (uint8)(0xF8); //Command byte
sendAs[2] = (uint8)(0x02); //Number of data words
sendAs[3] = (uint8)(0x14); //Extended command number
//sendBuffer[4] = Checksum16 (LSB)
//sendBuffer[5] = Checksum16 (MSB)

sendAs[7]=(uint8)(0xC0); // AsynchOptions
// Bit 7: Update
// Bit 6 :UARTEnable
// Bit 5: Reserved
//baud rate=19200
int high=64286/256;
int low=64286-(256*high);

extendedChecksum(sendAs, 10);

//Sending command to U6
sendChars = LJUSB_Write(hDevAsync, sendAs, 10);
if( sendChars < 10 )
if( sendChars == 0 )
printf("asynchConfig() error : write failed\n");
printf("asynchConfig() error : did not write all of the buffer\n");
return -1;

//Reading response from U6
recChars = LJUSB_Read(hDevAsync, recAs, 10);

if( recChars < 10 )
if( recChars == 0 )
printf("asynchConfig() error : read failed\n");
printf("asynchConfig() error : did not read all of the buffer\n");
return -1;


return 0;


The problem is that when I send an AsynchConfig command to the U6 in order to configure the UART for asynchronous communication, the U6 response has an errorcode 114 (decimal).

I wasn't able to find this errorcode on the U6 data sheet but I found it on the U3 documentation and the exaplanation says: UART NOT ENABLED.

But even if I send the message with bit 6 of byte 7 enabled the error does not change.

Am I missing something?

Thank you for your help.

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 31 May 2013 - 03:20 PM

Looks like the update bit of the the AsynchOptions is causing the error. You will only want to set bit 6 (0x40) when enabling UART. Also, you will want to swap your BaudFactor bytes since byte 8 is the lower byte and byte 9 is the higher.

#3 lucia

  • Members
  • 3 posts

Posted 03 June 2013 - 12:28 AM

Thank you for your help, I switched the low and high part of the baudfactor, and divided the asynchronous communication configuration in two operation (two commands to the U6): 1) baud rate set: sendAs[7]=0x80; and 2) UART enabled: senAs[7]=0x40; but still the two responses from U6 present an errorcode 114 and the baud rate is still set to 0. Is the sequence of operations correct?

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 03 June 2013 - 12:55 PM

I need to correct part of my first answer. You do actually want to set byte 7 to 0xCO in one AsynchConfig call. The update bit needs to be set for any setting changes to be made. Sorry about that.

I spoke with the firmware person, and it looks like error 114 is returned when it should be 113 (UART_NOTCONNECTED). Before calling AsynchConfig you will need to call ConfigIO and set the WriteMask bits 0 (Write settings) and 5 (Assign pins to UART), byte 6 = 0x21.


Timers/Counters/TimerCounterPinOffset can be set to zero unless you want them enabled or want to shift the TX/RX pins.

#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 03 June 2013 - 02:21 PM

We updated the AsynchConfig low-level documentation:


The AsynchOptions now mention to use ConfigIO first.

#6 lucia

  • Members
  • 3 posts

Posted 05 June 2013 - 03:09 AM

Now is working! Thank you for your help!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users