diff --git a/README.md b/README.md index 96f4b81..222f463 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,17 @@ Your code ends up sending and receiving serial frames through those library, nev On the Python side: ``` -import happyserial +from happyserial import HappySerial -def rx_cb(self,rxframe): - print(rxframe) # called each time Python receives a frame - -happyser = happyserial.Happyserial(rx_cb) - -... +def _happyserial_rx_cb(buf): + print('rx: {}'.format(buf)) + +happy = HappySerial.HappySerial( + serialport = 'COM41', + rx_cb = _happyserial_rx_cb, +) -happyser.send(txframe=[0x00,0x01,0x02,0x03]) +happy.tx([0x01,0x02,0x03]) ``` On the C side: @@ -56,16 +57,13 @@ On the C side: #include "happyserial.h" int main(void) { + uint8_t buf = {0x00,0x01,0x03}; happyserial_init(_happyserial_rx_cb); - ... - - happyserial_tx(buf,bufLen); + happyserial_tx(buf,sizeof(buf)); } -//=========================== interrupt handlers ============================== - void _happyserial_rx_cb(uint8_t* buf, uint8_t bufLen) { ... }