Do a wait_avalon_ready before sending a reset code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/driver-avalon.c b/driver-avalon.c
index 7792943..fe7582e 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -265,6 +265,15 @@ static int avalon_read(int fd, char *buf, ssize_t len)
return AVA_GETS_OK;
}
+/* Wait until the ftdi chip returns a CTS saying we can send more data. The
+ * status is updated every 40ms. */
+static void wait_avalon_ready(int fd)
+{
+ while (avalon_buffer_full(fd) == AVA_BUFFER_FULL) {
+ nmsleep(40);
+ }
+}
+
static int avalon_reset(struct cgpu_info *avalon, int fd)
{
struct avalon_result ar;
@@ -281,6 +290,8 @@ static int avalon_reset(struct cgpu_info *avalon, int fd)
AVALON_DEFAULT_MINER_NUM,
0, 0,
AVALON_DEFAULT_FREQUENCY);
+
+ wait_avalon_ready(fd);
ret = avalon_send_task(fd, &at, NULL);
if (unlikely(ret == AVA_SEND_ERROR))
return -1;
@@ -460,13 +471,6 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
}
}
-static void wait_avalon_ready(int fd)
-{
- while (avalon_buffer_full(fd) == AVA_BUFFER_FULL) {
- nmsleep(40);
- }
-}
-
static void avalon_idle(struct cgpu_info *avalon, struct avalon_info *info,
int fd)
{