summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <jaylink-dev@marcschink.de>2016-02-02 08:54:49 +0100
committerMarc Schink <jaylink-dev@marcschink.de>2016-02-02 08:54:49 +0100
commit7d697529a8db2018ecb5697413974fbbf9375b5b (patch)
tree2c559ab76ce55ea13cee2bdfc4d5706f4de1926a
parenta7074289fb24c258546dd746c08af0805cf4bfca (diff)
Update for libjaylink API changes
-rw-r--r--device_info.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/device_info.c b/device_info.c
index 109c527..e2954a4 100644
--- a/device_info.c
+++ b/device_info.c
@@ -33,11 +33,12 @@ int main(int argc, char **argv)
uint32_t interfaces;
uint32_t freq;
uint16_t div;
- uint32_t div2;
+ struct jaylink_swo_speed swo_speed;
uint8_t config[JAYLINK_DEV_CONFIG_SIZE];
bool use_serial_number;
uint32_t serial_number;
char *firmware_version;
+ size_t length;
bool device_found;
uint32_t tmp;
size_t i;
@@ -113,17 +114,17 @@ int main(int argc, char **argv)
printf("S/N: %012u\n", serial_number);
- ret = jaylink_get_firmware_version(devh, &firmware_version);
+ ret = jaylink_get_firmware_version(devh, &firmware_version, &length);
- if (ret > 0) {
+ if (ret != JAYLINK_OK) {
+ printf("jaylink_get_firmware_version() failed: %s.\n",
+ jaylink_strerror_name(ret));
+ jaylink_close(devh);
+ jaylink_exit(ctx);
+ return EXIT_FAILURE;
+ } else if (length > 0) {
printf("\nFirmware: %s\n", firmware_version);
free(firmware_version);
- } else if (ret < 0) {
- printf("jaylink_get_firmware_version() failed: %s.\n",
- jaylink_strerror_name(ret));
- jaylink_close(devh);
- jaylink_exit(ctx);
- return EXIT_FAILURE;
}
memset(caps, 0, JAYLINK_DEV_EXT_CAPS_SIZE);
@@ -226,7 +227,7 @@ int main(int argc, char **argv)
if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_SWO)) {
ret = jaylink_swo_get_speeds(devh, JAYLINK_SWO_MODE_UART,
- &freq, &div2);
+ &swo_speed);
if (ret != JAYLINK_OK) {
printf("jaylink_swo_get_speeds() failed: "
@@ -236,8 +237,9 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- printf("\nSWO speeds: %u MHz / div; div >= %u\n",
- freq / 1000000, div);
+ printf("\nSWO speeds: %u MHz / div; div >= %u and div <= %u\n",
+ swo_speed.freq / 1000000, swo_speed.min_div,
+ swo_speed.max_div);
}
if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {