0

I've been lastly working with Robot Framework in some low level tasks, so I have to manage some byte strings. I need to use the Convert To bytes keyword from the BuiltIn Library, but I can't find the way to handle Little Endian byte-ordered strings using this keyword.

I'm concerned that these types of operations are way easier to be handled directly in Python with user-defined keywords, but having in mind that a Built-In keyword is already thought to do this work for me, shouldn't it be able to work both in Big and Little Endian formats?

If someone could tell me if the Convert To Bytes keyword can also work in Little Endian in some way, or if there exist any other library apart from the BuiltIn supporting this format, I'll really appreciate that!

FranmR
  • 76
  • 7

1 Answers1

2

You can use the Evaluate keyword form builtin library. Here is a solution i cooked up from this answer. Alternatively you can modify this to fit your input data type.

***Variables***
${int}    1234

*** Test Cases ***  
test 
    ${byte_int}=    Evaluate    (${int}).to_bytes(((${int}).bit_length() + 7) // 8, byteorder='little')
    Log    ${byte_int}
Jiri Janous
  • 1,189
  • 1
  • 6
  • 14
  • Thanks for your reply! But I already knew about the `Evaluate` Keyword. I would that this is a limitation in `Convert to Bytes`, but as long as `Evaluate` exists, it is not that important. – FranmR Jul 13 '22 at 13:29