It is easy enough to use hidapi to get communications working with the Vybrid in Serial-USB. HidAPI supports Windows, Mac, FreeBSD and Linux. Most other HAB serial loader documentation is the same on the Vybrid. For example, I am migrating IMX25 code and the command structure is identical with a smaller allowed peripherals in the DCD. See chapter 19.8 of the Vybrid manual for more on the Serial-USB protocol.
Here is a hacked up version of hidtest.c,
/*******************************************************
Alan Ott - Signal 11 Software
Copyright 2009, All Rights Reserved.
This contents of this file may be used by anyone
for any reason without any conditions and may be
used as a starting point for your own applications
which use HIDAPI.
********************************************************/
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <stdlib.h>
#include "hidapi.h"
// Headers needed for sleeping.
#include <unistd.h>
int main(int argc, char* argv[])
{
int res;
unsigned char buf[256];
#define MAX_STR 255
wchar_t wstr[MAX_STR];
hid_device *handle;
int i;
if (hid_init())
return -1;
// Open the device using the VID, PID,
handle = hid_open(0x15a2, 0x6a, NULL); /* Vybrid */
if (!handle) {
printf("unable to open device\n");
return 1;
}
// Read the Manufacturer String
wstr[0] = 0x0000;
res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
if (res < 0)
printf("Unable to read manufacturer string\n");
printf("Manufacturer String: %ls\n", wstr);
// Read the Product String
wstr[0] = 0x0000;
res = hid_get_product_string(handle, wstr, MAX_STR);
if (res < 0)
printf("Unable to read product string\n");
printf("Product String: %ls\n", wstr);
// Read the Serial Number String
wstr[0] = 0x0000;
res = hid_get_serial_number_string(handle, wstr, MAX_STR);
if (res < 0)
printf("Unable to read serial number string\n");
printf("Serial Number String: (%d) %ls", wstr[0], wstr);
printf("\n");
// Read Indexed String 1
wstr[0] = 0x0000;
res = hid_get_indexed_string(handle, 1, wstr, MAX_STR);
if (res < 0)
printf("Unable to read indexed string 1\n");
printf("Indexed String 1: %ls\n", wstr);
// Set the hid_read() function to be non-blocking.
hid_set_nonblocking(handle, 1);
memset(buf,0,sizeof(buf));
// ERROR_STATUS (cmd 0x0505). The first byte is the report number (0x1).
buf[0] = 1; /* report 1 */
buf[1] = 5; /* ERROR_STATUS */
buf[2] = 5;
res = hid_write(handle, buf, 17);
if (res < 0) {
printf("Unable to write()\n");
printf("Error: %ls\n", hid_error(handle));
}
// Report 3 - engineering/production
res = 0;
while (res == 0) {
res = hid_read(handle, buf, sizeof(buf));
if (res == 0)
printf("waiting...\n");
if (res < 0)
printf("Unable to read()\n");
usleep(500*1000);
}
printf("Data read:\n ");
// Print out the returned buffer.
for (i = 0; i < res; i++)
printf("%02hhx ", buf[i]);
printf("\n");
// Report 4 - data returned to 0x0505 (ERROR_STATUS).
res = 0;
while (res == 0) {
res = hid_read(handle, buf, sizeof(buf));
if (res == 0)
printf("waiting...\n");
if (res < 0)
printf("Unable to read()\n");
usleep(500*1000);
}
printf("Data read:\n ");
// Print out the returned buffer.
for (i = 0; i < res; i++)
printf("%02hhx ", buf[i]);
printf("\n");
hid_close(handle);
/* Free static HIDAPI objects. */
hid_exit();
return 0;
}