k4be 3 лет назад
Родитель
Сommit
73035f89ba
2 измененных файлов с 8 добавлено и 0 удалено
  1. 5 0
      lpc.c
  2. 3 0
      serial.c

+ 5 - 0
lpc.c

@@ -68,6 +68,8 @@ struct lpc_device *lpc_setup(struct serial_device *port) {
 
 
 void lpc_init(struct lpc_device *dev) {
 void lpc_init(struct lpc_device *dev) {
   char buf[4096];
   char buf[4096];
+
+  serial_read(dev->port, buf, sizeof(buf), 0);
   
   
   serial_write(dev->port, "?");
   serial_write(dev->port, "?");
   
   
@@ -293,7 +295,10 @@ int lpc_await_reply(struct lpc_device *dev, ...) {
 int lpc_getline(struct lpc_device *dev, char *buf) {
 int lpc_getline(struct lpc_device *dev, char *buf) {
   if(sprog_waitdata(dev->port, dev->reply_time)==0)
   if(sprog_waitdata(dev->port, dev->reply_time)==0)
     return 0;
     return 0;
+//  sprog_info("fgets...\n");
   fgets(buf, 4096, dev->port->f);
   fgets(buf, 4096, dev->port->f);
+//  sprog_info("...fgets\n");
+//  sprog_info("--> %s\n", buf);
   return 1;
   return 1;
 }
 }
 
 

+ 3 - 0
serial.c

@@ -121,6 +121,8 @@ void serial_write(struct serial_device *port, const char *text) {
   int bytes;
   int bytes;
   bytes = strlen(text);
   bytes = strlen(text);
   i = 0;
   i = 0;
+
+//  sprog_info("<-- %s\n", text);
   
   
   while(bytes-i>0) {
   while(bytes-i>0) {
     b = write(port->fd, &text[i], bytes-i);
     b = write(port->fd, &text[i], bytes-i);
@@ -147,6 +149,7 @@ int serial_read(struct serial_device *port, char *buf, int len, int timeout) {
     if(FD_ISSET(port->fd, &readset))
     if(FD_ISSET(port->fd, &readset))
       bytes += read(port->fd, &buf[bytes], len-bytes);
       bytes += read(port->fd, &buf[bytes], len-bytes);
   }
   }
+//  buf[bytes]=0; sprog_info("--> %s\n", buf);
   return bytes;
   return bytes;
 }
 }