src/slcan_encode.c
/**
 * 
 * This decodes a SL Command
 * 
 * @param buf    The buffer to use
 * @param length The length of the buffer
 * @param pkt    The packet to encode
 * 
 * @return The number of bytes that were written to buf
 */
This decodes a SL Command

@param buf    The buffer to use
@param length The length of the buffer
@param pkt    The packet to encode

@return The number of bytes that were written to buf
This decodes a SL Command @param buf The buffer to use @param length The length of the buffer @param pkt The packet to encode @return The number of bytes that were written to buf
uint16_t encodeSLReply(uint8_t *buf, uint8_t length, SLPacket *pkt)
{
    if ((length == 0) || (buf == NULL) || (pkt == NULL)) {
        return false;
    }
    uint16_t index = 0;
    switch (pkt->type) {
        case Bad:
            buf[index++] = 7;
            break;
        case Frame:
            buf[index++] = 'z';
            buf[index++] = '\r';
            break;
        case Open:
        case Close:
        case Listen:
        case Speed:
        default:
            buf[index++] = '\r';
            break;
    }
    return index;
}
uint16_t encodeSLReply ( uint8_t * buf , uint8_t length , SLPacket * pkt ) { if ( ( length == 0 ) || ( buf == NULL ) || ( pkt == NULL ) ) { return false ; } uint16_t index = 0 ; switch ( pkt -> type ) { case Bad : buf [ index ++ ] = 7 ; break ; case Frame : buf [ index ++ ] = ' ' ; buf [ index ++ ] = ' \r ' ; break ; case Open : case Close : case Listen : case Speed : default : buf [ index ++ ] = ' \r ' ; break ; } return index ; }
This decodes a SL Command
This decodes a SL Command
// Packet Too Short