SR_PRIV gboolean sr_vc870_packet_valid(const uint8_t *buf) { struct vc870_info info; /* Byte 21: Always '\r' (carriage return, 0x0d, 13) */ /* Byte 22: Always '\n' (newline, 0x0a, 10) */ if (buf[21] != '\r' || buf[22] != '\n') return FALSE; parse_flags(buf, &info); return flags_valid(&info); }
SR_PRIV gboolean sr_metex14_packet_valid(const uint8_t *buf) { struct metex14_info info; memset(&info, 0x00, sizeof(struct metex14_info)); parse_flags((const char *)buf, &info); if (!flags_valid(&info)) return FALSE; if (buf[13] != '\r') return FALSE; return TRUE; }
/** * Check whether a received frame is valid. * * @param[in] buf The text buffer with received data. * * @return TRUE upon success, FALSE otherwise. */ SR_PRIV gboolean sr_asycii_packet_valid(const uint8_t *buf) { struct asycii_info info; /* First check whether we are in sync with the packet stream. */ if (buf[15] != '\r') return FALSE; /* Have the received packet content parsed. */ memset(&info, 0x00, sizeof(info)); parse_flags((const char *)buf, &info); if (!flags_valid(&info)) return FALSE; return TRUE; }
SR_PRIV gboolean sr_fs9922_packet_valid(const uint8_t *buf) { struct fs9922_info info; /* Byte 0: Sign (must be '+' or '-') */ if (buf[0] != '+' && buf[0] != '-') return FALSE; /* Byte 12: Always '\r' (carriage return, 0x0d, 13) */ /* Byte 13: Always '\n' (newline, 0x0a, 10) */ if (buf[12] != '\r' || buf[13] != '\n') return FALSE; parse_flags(buf, &info); return flags_valid(&info); }