#define SER_PORT "/dev/USB300"
#define SAVE_CONFIG "./learned.txt"
#define LEARN_TIME_S 1
#include <stdio.h>
int main(int argc, const char* argv[]) {
uint16_t recv=0;
printf("Opening Connection to USB300 \n");
if (myGateway.
Open(SER_PORT)!=OK)
{
printf("Failed to open USB300\n");
return 0;
}
if (cmd.ReadVersion(version) == OK)
{
printf("%s %i.%i.%i.%i, ID:0x%08lX on %s\n",
SER_PORT);
}
else
{
printf("Failed to retrieve USB300 version\n");
return -1;
}
if (cmd.BIST() == OK)
printf ("Successful BIST performed!\n");
else
{
printf("Failed to perform BIST\n");
return -1;
}
if (cmd.ReadIDBase(baseID) == OK)
else
{
printf("Failed to retrieve USB300 base ID\n");
return -1;
}
uint8_t repLevel = 1;
if (cmd.WriteRepeater(true, repLevel) == OK)
printf("Repeater added!\n");
else
{
printf("Failed to add repeater\n");
return -1;
}
if (cmd.ReadRepeater(repeater) == OK)
printf(
"Enabled: %s, Level: %i\n", repeater.
repEnable ?
"true":
"false", repeater.
repLevel);
else
{
printf("Failed to read repetear\n");
return -1;
}
if (cmd.AddFilter(
CHOICE,0x11223344, BLOCK) == OK)
printf("Filter added!\n");
else
{
printf("Failed to add filter\n");
return -1;
}
uint8_t filterCount;
if (cmd.ReadFilter(filter, &filterCount, 1) == OK)
printf("Filter type: %i, Filter value: 0x%08lX\n", filter[0].filterType, filter[0].filterValue);
else
{
printf("Failed to read filter\n");
return -1;
}
if (cmd.DeleteFilter(
CHOICE, 0x11223344) == OK)
printf("Filter deleted\n");
else
{
printf("Failed to delete filter\n");
return -1;
}
if (cmd.EnableFilter(
true,
OR) == OK)
printf("Filter enabled\n");
else
{
printf("Failed to enable filter\n");
return -1;
}
if (cmd.DeleteAllFilter() == OK)
printf("All filter has been deleted!\n");
else
{
printf("Failed to delete all filter\n");
return -1;
}
if (cmd.WaitMaturity(true) == OK)
printf("Maturity turned on\n");
else
{
printf("Failed to turn on maturity\n");
return -1;
}
return 0;
}