34 lines
645 B
C
34 lines
645 B
C
#include "hdlc.h"
|
|
#include <stdio.h>
|
|
|
|
struct HDLC hdlc;
|
|
|
|
void hdlc_sendMsg() {
|
|
uint8_t msg[] = "Hello world!";
|
|
HDLC_transmitBlock(&hdlc, msg, sizeof(msg));
|
|
}
|
|
|
|
void hdlc_receiveMsg() {
|
|
int16_t resp = HDLC_receive(&hdlc);
|
|
if(resp != 0U)
|
|
{
|
|
uint8_t buff[hdlc.RXBFLEN];
|
|
uint16_t size = HDLC_copyReceivedMessage(&hdlc, buff);
|
|
|
|
printf("Msg[%u]=%s\n", size, buff);
|
|
}
|
|
}
|
|
|
|
//нужно указать 2 функции на чтение и запись байтов, чтобы работало
|
|
int main(void)
|
|
{
|
|
HDLC_init(&hdlc);
|
|
|
|
hdlc_sendMsg();
|
|
|
|
for(;;)
|
|
{
|
|
hdlc_receiveMsg();
|
|
}
|
|
}
|