Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. DLMS Image Transfer: “byte Must Be In Range(0, 256)” With 512-byte Block Size In Python

DLMS Image Transfer: “byte must be in range(0, 256)” with 512-byte block size in Python

By Kumaresh , 24 August, 2026
Forums
Gurux DLMS for Python

Hi Gurux Team,

I am facing an issue with FOTA Image Block Transfer in Gurux.DLMS Python.

The same meter and firmware FOTA work correctly using DLMS Director, but when I perform the same operation using the Python implementation, Image Transfer Initiate succeeds and Image Block Transfer fails with:

   byte must be in range(0, 256)

The meter reports:

   Image Block Size : 512 bytes
   Image Transfer Enabled : True

Image Transfer Initiate (Method 1) is successful.

The failure occurs when sending Method 2 (Image Block Transfer), starting from Block 0.

The decrypted DLMS request shows:

   Structure
     UInt32 block number = 0
     OctetString = 512 bytes

and the encoded OCTET STRING contains:

   09 82 02 00

The complete communication log and current Python source code are attached.

Since the same FOTA works successfully with DLMS Director, could you please explain:

1. Why does the Python implementation generate the
  "byte must be in range(0, 256)" error?

2. Is this related to the 512-byte OCTET STRING encoding,
  GXByteBuffer, AXDR length encoding, or PDU/frame size?

3. What is the correct fix in the Gurux Python code so that
  FOTA works the same way as DLMS Director?

Please point me to the exact code/function that needs to be changed.

Thank you
Kumaresh Dhara

Logs attached
======================================================================
                FOTA CONFIGURATION
======================================================================
FOTA Mode       : SEQUENTIAL
Firmware Path   : D:\Script P_Shell\DLMS FOTA Tool\Testing_2024.bin
Firmware file found successfully.

Starting FOTA Update...

======================================================================
               FOTA UPDATE STARTED
======================================================================
FOTA MODE : SEQUENTIAL
Firmware File : D:\Script P_Shell\DLMS FOTA Tool\Testing_2024.bin
Firmware Size : 261120 bytes
Image Transfer Object Found : 0.0.44.0.0.255

Reading Image Block Size from meter...
Decrypted PDU: C0 01 C1 00 12 00 00 2C 00 00 FF 02 00
<GetRequest>
 <GetRequestNormal>
   <InvokeIdAndPriority Value="C1" />
   <AttributeDescriptor>
     <ClassId Value="0012" />
     <InstanceId Value="00002C0000FF" />
     <AttributeId Value="02" />
   </AttributeDescriptor>
 </GetRequestNormal>
</GetRequest>

TX: 00:14:47    7E A0 2C 03 61 10 BC BE E6 E6 00 C8 1E 30 00 00 AC 95 59 95 7C 48 74 F9 A4 D2 3D F9 DB B7 C2 44 80 CF C5 67 18 A2 18 49 8C 45 BE 99 4C 7E
Encryption is applied.
Authentication is applied.
Decrypted PDU: C4 01 C1 00 06 00 00 02 00
<GetResponse>
 <GetResponseNormal>
   <InvokeIdAndPriority Value="C1" />
   <Result>
     <Data>
       <UInt32 Value="00000200" />
     </Data>
   </Result>
 </GetResponseNormal>
</GetResponse>

RX: 00:14:47    7E A0 28 61 03 30 42 0B E6 E7 00 CC 1A 30 00 00 AC 94 5A BE 51 E9 76 D6 62 7D 96 C0 7C D6 57 21 F5 C8 6E 47 F0 2D 99 89 27 7E
Meter Image Block Size : 512
Using Image Block Size : 512 bytes
Decrypted PDU: C0 01 C1 00 12 00 00 2C 00 00 FF 05 00
<GetRequest>
 <GetRequestNormal>
   <InvokeIdAndPriority Value="C1" />
   <AttributeDescriptor>
     <ClassId Value="0012" />
     <InstanceId Value="00002C0000FF" />
     <AttributeId Value="05" />
   </AttributeDescriptor>
 </GetRequestNormal>
</GetRequest>

TX: 00:14:47    7E A0 2C 03 61 32 AC BC E6 E6 00 C8 1E 30 00 00 AC 96 52 3C EC B5 64 6F 12 51 D0 20 EF 77 5A 06 3D F1 54 99 E5 B4 F0 A3 AF 33 6C F6 94 7E
Encryption is applied.
Authentication is applied.
Decrypted PDU: C4 01 C1 00 03 01
<GetResponse>
 <GetResponseNormal>
   <InvokeIdAndPriority Value="C1" />
   <Result>
     <Data>
       <Boolean Value="True" />
     </Data>
   </Result>
 </GetResponseNormal>
</GetResponse>

RX: 00:14:48    7E A0 25 61 03 52 D9 C0 E6 E7 00 CC 17 30 00 00 AC 95 B4 60 04 36 8A 4C 3C EB 7E 03 BF 6D DC B8 0A 77 31 2C A5 E5 7E
Image Transfer Enabled : True
Image Identifier : Testing_2024.bin

Reading firmware file...
Firmware loaded successfully : 261120 bytes
Total Blocks : 510

----------------------------------------------------------------------
SEQUENTIAL MODE SELECTED
Starting from Block 0
----------------------------------------------------------------------

----------------------------------------------------------------------
STEP 1 : IMAGE TRANSFER INITIATE
----------------------------------------------------------------------
Decrypted PDU: C3 01 C1 00 12 00 00 2C 00 00 FF 01 01 02 02 09 50 54 65 73 74 69 6E 67 5F 66 75 6C 6C 69 6D 61 67 65 5F 54 61 74 61 5F 31 50 5F 34 47 5F 43 53 50 44 43 4C 5F 4B 55 31 20 30 31 2E 32 34 2D 53 4B 30 33 30 30 2E 31 36 5F 54 41 43 48 30 2E 30 30 2E 34 32 5F 43 52 59 5F 32 30 32 34 2E 62 69 6E 06 00 03 FC 00
<ActionRequest>
 <ActionRequestNormal>
   <InvokeIdAndPriority Value="C1" />
   <MethodDescriptor>
     <ClassId Value="0012" />
     <InstanceId Value="00002C0000FF" />
     <MethodId Value="01" />
   </MethodDescriptor>
   <MethodInvocationParameters>
     <Structure Qty="02" >
       <OctetString Value="54657374696E675F66756C6C696D6167655F546174615F31505F34475F43535044434C5F4B55312030312E32342D534B303330302E31365F54414348302E30302E34325F4352595F323032342E62696E" />
       <UInt32 Value="0003FC00" />
     </Structure>
   </MethodInvocationParameters>
 </ActionRequestNormal>
</ActionRequest>

TX: 00:14:48    7E A0 85 03 61 54 C2 E1 E6 E6 00 CB 77 30 00 00 AC 97 76 22 CD B3 6C AC 73 FA F2 BC 39 86 D3 8B 57 99 51 CB 61 D5 77 79 97 A2 85 6F A1 BC 9C 48 11 49 CE 9B AE E5 7C E0 1B 5D 49 BE 3C DC B6 9B 75 A8 0B AB 2B F5 73 9E FF 42 17 98 87 FB 19 44 20 46 90 E4 63 0F 62 DE A8 B8 84 F5 EC ED 54 C6 6D 95 68 66 E3 53 F3 7F B2 DF 79 FC FE 5A B3 F3 E6 D9 FB 4C C9 75 8F 2B 0D DE 92 24 12 06 0D EF 91 D1 94 03 A1 6B 7E
Encryption is applied.
Authentication is applied.
Decrypted PDU: C7 01 C1 00 00
<ActionResponse>
 <ActionResponseNormal>
   <InvokeIdAndPriority Value="C1" />
   <Result Value="Success" />
 </ActionResponseNormal>
</ActionResponse>

RX: 00:14:48    7E A0 24 61 03 74 56 98 E6 E7 00 CF 16 30 00 00 AC 96 FB 09 C0 02 1E 55 0C B9 F8 52 D7 F1 2F 01 6C 44 86 7C D2 7E
Image Transfer Initiate : SUCCESS

----------------------------------------------------------------------
STEP 2 : IMAGE BLOCK TRANSFER
----------------------------------------------------------------------
Start Block : 0
End Block   : 509
Block Size  : 512

Sending Block 0/509 | 512 bytes
Decrypted PDU: C3 01 C1 00 12 00 00 2C 00 00 FF 02 01 02 02 06 00 00 00 00 09 82 02 00 86 15 FF FF 79 19 A6 16 00 00 6C 16 00 00 8D 16 00 00 00 00 CA 18 89 18 00 00 00 00 00 00 59 18 4B 16 14 18 00 00 2B 17 00 00 00 00 FD 18 F7 16 00 00 00 00 5C 19 00 00 E0 15 BF 16 00 00 11 17 00 00 00 00 E8 15 00 00 00 00 92 16 00 00 A1 16 9C 16 97 16 00 00 00 00 7B 19 00 00 00 00 BD 16 7D 19 00 00 00 00 00 00 00 00 00 00 A8 16 AE 16 B3 16 B8 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7E 3F E0 84 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF 32 00 85 D2 3F BF 1C 95 33 C0 74 5D 82 BF 0E BE 33 C0 00 00 80 41 D2 08 00 40 00 00 80 3F C6 3C 00 40 00 F0 73 45 04 C6 4B 45 48 BC 4D 47 3B 57 A2 47 70 C3 23 4D 70 C3 23 4D 70 C3 23 4D BE 38 81 4D BE 38 81 4D BE 38 81 4D DA 00 00 00 E2 00 00 00 EA 00 00 00 F2 00 00 00 01 00 40 42 0F 00 20 A1 07 00 01 00 40 42 0F 00 20 A1 07 00 0A D7 23 3C 66 66 E6 3F 00 00 20 41 00 00 20 42 00 00 8C 42 00 00 48 41 80 0C 00 00 00 00 F0 41 01 01 01 00 04 04 01 03 00 00 00 00 06 00 96 00 00 00 2A 43 00 80 84 43 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
<ActionRequest>
 <ActionRequestNormal>
   <InvokeIdAndPriority Value="C1" />
   <MethodDescriptor>
     <ClassId Value="0012" />
     <InstanceId Value="00002C0000FF" />
     <MethodId Value="02" />
   </MethodDescriptor>
   <MethodInvocationParameters>
     <Structure Qty="02" >
       <UInt32 Value="00000000" />
       <OctetString Value="8615FFFF7919A61600006C1600008D1600000000CA18891800000000000059184B16141800002B1700000000FD18F716000000005C190000E015BF160000111700000000E8150000000092160000A1169C169716000000007B1900000000BD167D1900000000000000000000A816AE16B316B816000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007E3FE08400000000000000000000FFFFFFFFFFFFFFFFFFFF320085D23FBF1C9533C0745D82BF0EBE33C000008041D20800400000803FC63C004000F0734504C64B4548BC4D473B57A24770C3234D70C3234D70C3234DBE38814DBE38814DBE38814DDA000000E2000000EA000000F2000000010040420F0020A10700010040420F0020A107000AD7233C6666E63F000020410000204200008C4200004841800C00000000F0410101010004040103000000000600960000002A430080844303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" />
     </Structure>
   </MethodInvocationParameters>
 </ActionRequestNormal>
</ActionRequest>

byte must be in range(0, 256)
DisconnectRequest
TX: 00:14:48    7E A0 11 03 61 76 F1 7F E6 E6 00 62 03 80 01 00 BD 9B 7E
RX: 00:14:48    7E A0 36 61 03 96 9D A6 E6 E7 00 63 28 80 01 00 BE 23 04 21 28 1F 30 00 00 AC 96 34 08 07 5D 01 C2 CD C8 12 1B D5 6E 0F E7 51 E4 A3 E7 8B B7 DF 4F 87 6A A5 9F 49 BB 7E
TX: 00:14:48    7E A0 07 03 61 53 65 81 7E
RX: 00:14:49    7E A0 20 61 03 73 05 9E 81 80 14 05 02 03 40 06 02 03 40 07 04 00 00 00 01 08 04 00 00 00 01 B7 29 7E
Ended. Press any key to continue.

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96

New forum topics

  • DLMS Image Transfer: “byte must be in range(0, 256)” with 512-byte block size in Python
  • Connecting to meter using Wrapper
  • DLMS Server / Meter emulation in Golang library
  • Unknown Baudrate
  • negative indexing for custom method/attribute
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin