9 #define DEFAULT_DEV "/dev/flink0" 12 int main(
int argc,
char* argv[]) {
16 uint8_t subdevice_id = 0;
24 while((c = getopt(argc, argv,
"d:s:o:v:rw")) != -1) {
30 subdevice_id = atoi(optarg);
33 offset = atoi(optarg);
43 fprintf(stderr,
"You can not set a value if you want to read from a device!");
50 if(optopt ==
'd' || optopt ==
's' || optopt ==
'o' || optopt ==
'v') fprintf(stderr,
"Option -%c requires an argument.\n", optopt);
51 else if(isprint(optopt)) fprintf (stderr,
"Unknown option `-%c'.\n", optopt);
52 else fprintf(stderr,
"Unknown option character `\\x%x'.\n", optopt);
59 printf(
"Opening device %s...\n", dev_name);
62 printf(
"Failed to open device!\n");
69 printf(
"Writing 0x%x (%u) to offset 0x%x at subdevice %u on device %s...\n", value, value, offset, subdevice_id, dev_name);
72 printf(
"Failure while writing to device: %u!\n", error);
77 printf(
"Reading from offset 0x%x at subdevice %u on device %s...\n", offset, subdevice_id, dev_name);
80 printf(
"Failure while reading from device: %u!\n", error);
84 printf(
"--> Read: 0x%x (%u)\n", value, value);
88 printf(
"Closing device %s...\n", dev_name);
flink_dev * flink_open(const char *file_name)
Opens a flink device file.
int flink_close(flink_dev *dev)
Close an open flink device.
ssize_t flink_read(flink_subdev *subdev, uint32_t offset, uint8_t size, void *rdata)
Read from a flink subdevice.
flink_subdev * flink_get_subdevice_by_id(flink_dev *dev, uint8_t subdev_id)
Find subdevice of a device with a given id.
int main(int argc, char *argv[])
ssize_t flink_write(flink_subdev *subdev, uint32_t offset, uint8_t size, void *wdata)
Write to a flink subdevice.