From 8d566f92cbc1ff2b4e346f46d0ab84b77fd6ff1e Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Sun, 23 Apr 2023 14:37:08 -0400 Subject: [PATCH] Fixing fax background service BMP output. --- owrx/fax.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/owrx/fax.py b/owrx/fax.py index 3b8bb874..35ae26db 100644 --- a/owrx/fax.py +++ b/owrx/fax.py @@ -182,8 +182,13 @@ class FaxParser(ThreadModule): self.ioc = self.data[6] * 4 self.lpm = self.data[7] self.line = 0 + # Find total header size + headerSize = 54 + (4*256 if self.depth==8 else 0) # 256x4 palette follows the header - self.colors = self.data[54:54+4*256] if self.depth==8 else None + if headerSize>54: + self.colors = self.data[54:headerSize] + else + self.colors = None # Find mode name and time modeName = "IOC-%d %dLPM" % (self.ioc, self.lpm) timeStamp = datetime.utcnow().strftime("%H:%M:%S") @@ -196,7 +201,7 @@ class FaxParser(ThreadModule): if self.service: # Create a new image file and write BMP header self.newFile(fileName) - self.writeFile(self.data[0:54]) + self.writeFile(self.data[0:headerSize]) else: # Compose result out = { @@ -210,7 +215,7 @@ class FaxParser(ThreadModule): "frequency": self.frequency } # Remove parsed data - del self.data[0:54+(4*256 if self.depth==8 else 0)] + del self.data[0:headerSize] except Exception as exptn: logger.debug("Exception parsing: %s" % str(exptn))