mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 16:29:04 -06:00
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#include <Fw/Types/StringUtils.hpp>
|
|
#include <LinuxI2cDriverTester.hpp>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <unistd.h>
|
|
|
|
TEST(TestNominal,Nominal) {
|
|
|
|
Drv::LinuxI2cDriverTester tester;
|
|
|
|
}
|
|
|
|
const char* help = "[-h] -d <I2C device> -a <I2C address> <byte 0> <byte1> ... <byteN>";
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
int c;
|
|
|
|
U32 addr = 0;
|
|
char device[80];
|
|
device[0] = 0;
|
|
|
|
while ((c = getopt (argc, argv, "hd:a:")) != -1) {
|
|
switch (c) {
|
|
case 'h':
|
|
printf("test_ut %s\n",argv[0],help);
|
|
return 0;
|
|
case 'a':
|
|
addr = strtoul(optarg,0,0);
|
|
break;
|
|
case 'd':
|
|
(void) Fw::StringUtils::string_copy(device, optarg, sizeof(device));
|
|
break;
|
|
default:
|
|
printf("test_ut %s\n",argv[0],help);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
printf("Address: %d (0x%02X) Device: %s\n",addr,addr,device);
|
|
|
|
U8 data[12];
|
|
|
|
for (int i = optind; i < argc; i++) {
|
|
data[optind-i] = strtoul(argv[i],0,0);
|
|
printf("Data: %s 0x%02X\n",argv[i],data[optind-i]);
|
|
}
|
|
|
|
Drv::LinuxI2cDriverTester tester;
|
|
tester.open(device);
|
|
|
|
tester.sendData(addr,data,argc-optind);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|