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);
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)
{
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
*/
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 */