Refactoring code. Redefined TagPacket struct and keytag_init to support the new imple...
authorqwert <qwert@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 23 Jul 2008 15:31:52 +0000 (15:31 +0000)
committerqwert <qwert@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 23 Jul 2008 15:31:52 +0000 (15:31 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1510 38d2e660-2303-0410-9eaa-f027e97ec537

app/triface/triface.c
bertos/net/keytag.c
bertos/net/keytag.h

index 4b45f221471a1b2ef9db853de07c2f27d4473e78..c807eac55ecb4467e0d6134388155c3d58343ea2 100644 (file)
@@ -84,10 +84,7 @@ int main(void)
        ser_init(&tag_ser, TAG_SER_PORT);
        ser_setbaudrate(&tag_ser, TAG_SER_BAUDRATE);
 
-       pkt.comm_ser = &fd_ser;
-       pkt.tag_ser = &tag_ser;
-
-       keytag_init(&pkt);
+       keytag_init(&pkt, &fd_ser.fd, &tag_ser.fd);
 
        protocol_init(&fd_ser.fd);
 
index 861169b488a9360561727e7e139def414d08cb4e..68b51997d1e1d1cd376dd555c14bfa9b4ab41905 100644 (file)
@@ -58,17 +58,20 @@ static void keytag_clearPkt(struct TagPacket *pkt)
        pkt->len = 0;
 }
 
-       void keytag_init(struct TagPacket *pkt)
-       {
-               keytag_clearPkt(pkt);
-       }
+void keytag_init(struct TagPacket *pkt, struct KFile *comm, struct KFile *tag)
+{
+       keytag_clearPkt(pkt);
+       pkt->host = comm;
+       pkt->tag = tag;
+
+}
 
        void keytag_poll(struct TagPacket *pkt)
 {
        int c;
 
        /* Get all chars from buffer */
-       while ((c = kfile_getc(&pkt->tag_ser->fd)) != EOF)
+       while ((c = kfile_getc(pkt->tag)) != EOF)
        {
                /* Search for STX char in received chars */
                if (c == TAG_STX)
@@ -86,7 +89,7 @@ static void keytag_clearPkt(struct TagPacket *pkt)
                        {
                                pkt->buf[TAG_MAX_PRINT_CHARS] = '\x0';
                                /* Write read TAG on communication serial */
-                               kfile_printf(&pkt->comm_ser->fd, "tag %s", pkt->buf);
+                               kfile_printf(pkt->host, "tag %s", pkt->buf);
                                pkt->sync = false;
                        }
                        else
index 541005ea694c9fdb969cce3b637098ef186e5d3d..b815a8b1b117328d770a347d55a5665d846887e0 100644 (file)
  */
 typedef struct TagPacket
 {
-       KFileSerial *tag_ser;           // Tag serial
-       KFileSerial *comm_ser;        // Communication serial
-       bool sync;                      // Status flag: true if we find an STX
-       uint16_t len;                   // Packet lenght
-       uint8_t buf[TAG_MAX_LEN];       // Reception buffer
+       KFile *tag;                         ///<Tag communication channel
+       KFile *host;                ///<Host communication channel
+       bool sync;                  ///< Status flag: true if we find an STX
+       uint16_t len;               ///< Packet lenght
+       uint8_t buf[TAG_MAX_LEN];       ///< Reception buffer
 } TagPacket;
 
-void keytag_init(struct TagPacket *pkt);
+void keytag_init(struct TagPacket *pkt, struct KFile *comm, struct KFile *tag);
 void keytag_poll(struct TagPacket *pkt);
 
 #endif /* NET_TAG_H */