• R/O
  • HTTP
  • SSH
  • HTTPS

kz_h8write: Commit

H8/3069F writer for KOZOS - kz_h8write


Commit MetaInfo

Revisionca0ba5917f8008aed0c618ca5045f33737e8f1eb (tree)
Zeit2012-04-28 11:27:21
AutorShinichiro Nakamura <shinta.main.jp@gmai...>
CommiterShinichiro Nakamura

Log Message

Bug fixed.

Ändern Zusammenfassung

Diff

--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ SRCS2=motdump.c mot.c
77 all: $(TARGET1) $(TARGET2)
88
99 clean:
10- rm -f $(TARGET1) $(TARGET2)
10+ @rm -f $(TARGET1) $(TARGET2)
1111
1212 $(TARGET1):$(SRCS1)
1313 $(CC) -o $(TARGET1) $(SRCS1) -std=c99 -g -Wall
--- a/serial.h
+++ b/serial.h
@@ -7,9 +7,9 @@
77 /*
88 * ===============================================================
99 * Serial interface library
10- * Version 0.0.3
10+ * Version 0.0.4
1111 * ===============================================================
12- * Copyright (c) 2010-2011 Shinichiro Nakamura
12+ * Copyright (c) 2010-2012 Shinichiro Nakamura
1313 *
1414 * Permission is hereby granted, free of charge, to any person
1515 * obtaining a copy of this software and associated documentation
--- a/serial_linux.c
+++ b/serial_linux.c
@@ -7,9 +7,9 @@
77 /*
88 * ===============================================================
99 * Serial interface library
10- * Version 0.0.3
10+ * Version 0.0.4
1111 * ===============================================================
12- * Copyright (c) 2010-2011 Shinichiro Nakamura
12+ * Copyright (c) 2010-2012 Shinichiro Nakamura
1313 *
1414 * Permission is hereby granted, free of charge, to any person
1515 * obtaining a copy of this software and associated documentation
@@ -260,12 +260,14 @@ int serial_read_with_timeout(SERIAL * s,
260260 int r = read(s->fd, buf + i, 1);
261261 if (r < 0) {
262262 e = 1;
263+ break;
263264 }
264265 } else {
265266 /*
266267 * タイムアウトが発生した.
267268 */
268269 e = 2;
270+ break;
269271 }
270272 }
271273
--- a/serial_windows.c
+++ b/serial_windows.c
@@ -7,9 +7,9 @@
77 /*
88 * ===============================================================
99 * Serial interface library
10- * Version 0.0.3
10+ * Version 0.0.4
1111 * ===============================================================
12- * Copyright (c) 2010-2011 Shinichiro Nakamura
12+ * Copyright (c) 2010-2012 Shinichiro Nakamura
1313 *
1414 * Permission is hereby granted, free of charge, to any person
1515 * obtaining a copy of this software and associated documentation
@@ -207,31 +207,33 @@ int serial_read_with_timeout(SERIAL * s,
207207 unsigned char *buf, const size_t size, const int ms)
208208 {
209209 int e = 0;
210- DWORD cnt = 0;
211210 DWORD total = 0;
212211
213212 /*
214213 * タイムアウトを設定して読み込みを実行する.
215214 */
216215 COMMTIMEOUTS cto;
217- cto.ReadIntervalTimeout = 0;
216+ cto.ReadIntervalTimeout = MAXDWORD;
218217 cto.ReadTotalTimeoutConstant = ms;
219- cto.ReadTotalTimeoutMultiplier = 0;
220- if(!SetCommTimeouts(s->handle, &cto)){
221- e = 1;
222- }
223-
224- /*
225- * 読み込みを実行する.
226- */
227- while (total < size) {
228- ReadFile(s->handle, buf, size, &cnt, NULL);
229- if (cnt != size) {
230- e = 2;
231- break;
218+ cto.ReadTotalTimeoutMultiplier = MAXDWORD;
219+ if(SetCommTimeouts(s->handle, &cto)){
220+ /*
221+ * 読み込みを実行する.
222+ */
223+ while (total < size) {
224+ DWORD cnt = 0;
225+ ReadFile(s->handle, buf + total, 1, &cnt, NULL);
226+ if (cnt != 1) {
227+ e = 2;
228+ break;
229+ }
230+ total += cnt;
232231 }
233- total += cnt;
234- buf += cnt;
232+ } else {
233+ /*
234+ * タイムアウトの設定に失敗した。
235+ */
236+ e = 1;
235237 }
236238
237239 return e;
Show on old repository browser