summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3ea30c1)
Instead of trying to re-use the same file descriptor, close and
re-open the device each time around the loop to avoid getting stuck
when calibrating TeleMega boards.
Signed-off-by: Keith Packard <keithp@keithp.com>
-do_cal(struct cc_usb *usb) {
+do_cal(char *tty) {
+ struct cc_usb *usb = NULL;
struct flash *b;
char line[1024];
double measured_freq;
struct flash *b;
char line[1024];
double measured_freq;
int cur_freq;
int cur_cal;
int new_cal;
int cur_freq;
int cur_cal;
int new_cal;
-
- cc_usb_printf(usb, "E 0\n");
+ usb = cc_usb_open(tty);
+
+ if (!usb)
+ exit(1);
+
+ cc_usb_printf(usb, "E 0\n");
+
+ cc_usb_sync(usb);
cc_usb_printf(usb, "C 1\n");
cc_usb_sync(usb);
cc_usb_printf(usb, "C 1\n");
cc_usb_sync(usb);
if (!cur_cal_words || !cur_freq_words) {
printf("no response\n");
if (!cur_cal_words || !cur_freq_words) {
printf("no response\n");
}
cur_cal = atoi(cur_cal_words[2]);
}
cur_cal = atoi(cur_cal_words[2]);
cc_usb_printf (usb, "c f %d\nc w\n", new_cal);
cc_usb_sync(usb);
cc_usb_printf (usb, "c f %d\nc w\n", new_cal);
cc_usb_sync(usb);
+ if (usb)
+ cc_usb_close(usb);
+ return ret;
- struct cc_usb *cc = NULL;
char *tty = NULL;
int success;
int verbose = 0;
char *tty = NULL;
int success;
int verbose = 0;
if (!tty)
tty="/dev/ttyACM0";
if (!tty)
tty="/dev/ttyACM0";
- cc = cc_usb_open(tty);
-
- if (!cc)
- exit(1);
-
- if (!do_cal(cc))