From 666e18c57e0b059d5feded716a549e63194ce7af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 16 Jun 2018 21:41:29 +0200 Subject: [PATCH] allow PayloadBuilder to be rewound --- gex/PayloadBuilder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gex/PayloadBuilder.py b/gex/PayloadBuilder.py index ad84ac0..473b880 100644 --- a/gex/PayloadBuilder.py +++ b/gex/PayloadBuilder.py @@ -13,6 +13,10 @@ class PayloadBuilder: """ Get the byte buffer """ return self.buf + def reset(self): + """ Clear the buffer """ + self.buf.clear() + def u8(self, num:int): """ Add a uint8_t """ self.buf.extend((num&0xFF).to_bytes(length=1, byteorder=self.endian, signed=False))