coveralls: 
[![Coverage Status](https://coveralls.io/builds/15706170/badge)](https://coveralls.io/builds/15706170)

Coverage increased (+0.002%) to 98.68% when pulling **f70ca7456ba0dacfd653fcdaf2fd2dea8abfe113 on fix-issue-124** into **8f491d8dda1a217d9233b0f4680e11c52dafaa2a on master**.

diff --git a/simulators/active_surface.py b/simulators/active_surface.py
index 5bea129..afd751a 100644
--- a/simulators/active_surface.py
+++ b/simulators/active_surface.py
@@ -579,7 +579,7 @@ class System(ListeningSystem):
                 self.drivers[params[0]].current_position
             )
 
-            val = utils.binary_to_bytes(binary_position)
+            val = utils.binary_to_bytes(binary_position, little_endian=False)
 
             if params[1] == 0xFA:
                 retval += val
@@ -642,7 +642,10 @@ class System(ListeningSystem):
             else:
                 return self.byte_nak
         else:
-            frequency = utils.bytes_to_int([chr(x) for x in params[2]])
+            frequency = utils.bytes_to_int(
+                [chr(x) for x in params[2]],
+                little_endian=False
+            )
 
             if frequency >= 20 and frequency <= 10000:
                 if params[0] == -1:
@@ -669,7 +672,10 @@ class System(ListeningSystem):
             else:
                 return self.byte_nak
         else:
-            frequency = utils.bytes_to_int([chr(x) for x in params[2]])
+            frequency = utils.bytes_to_int(
+                [chr(x) for x in params[2]],
+                little_endian=False
+            )
 
             if frequency >= 20 and frequency <= 10000:
                 if params[0] == -1:
@@ -714,7 +720,8 @@ class System(ListeningSystem):
                 return self.byte_nak
         else:
             reference_position = utils.bytes_to_int(
-                [chr(x) for x in params[2]]
+                [chr(x) for x in params[2]],
+                little_endian=False
             )
 
             if params[0] == -1:
@@ -811,7 +818,10 @@ class System(ListeningSystem):
             else:
                 return self.byte_nak
         else:
-            absolute_position = utils.bytes_to_int([chr(x) for x in params[2]])
+            absolute_position = utils.bytes_to_int(
+                [chr(x) for x in params[2]],
+                little_endian=False
+            )
 
             if params[0] == -1:
                 for driver in self.drivers:
@@ -829,7 +839,10 @@ class System(ListeningSystem):
             else:
                 return self.byte_nak
         else:
-            relative_position = utils.bytes_to_int([chr(x) for x in params[2]])
+            relative_position = utils.bytes_to_int(
+                [chr(x) for x in params[2]],
+                little_endian=False
+            )
 
             if params[0] == -1:
                 for driver in self.drivers:
@@ -867,7 +880,10 @@ class System(ListeningSystem):
             else:
                 return self.byte_nak
         else:
-            velocity = utils.bytes_to_int([chr(x) for x in params[2]])
+            velocity = utils.bytes_to_int(
+                [chr(x) for x in params[2]],
+                little_endian=False
+            )
 
             if velocity > 100000 or velocity < -100000:
                 if params[0] == -1:
diff --git a/simulators/acu.py b/simulators/acu.py
index 2beeb1a..6faa96e 100644
--- a/simulators/acu.py
+++ b/simulators/acu.py
@@ -17,8 +17,8 @@ from simulators.common import ListeningSystem, SendingSystem
 servers = []
 servers.append((('127.0.0.1', 13000), ('127.0.0.1', 13001), ()))
 
-start_flag = b'\x1D\xFC\xCF\x1A'
-end_flag = b'\xA1\xFC\xCF\xD1'
+start_flag = b'\x1A\xCF\xFC\x1D'
+end_flag = b'\xD1\xCF\xFC\xA1'
 
 
 class System(ListeningSystem, SendingSystem):
@@ -80,7 +80,7 @@ class System(ListeningSystem, SendingSystem):
             return False
 
         if len(self.msg) == 8:
-            self.msg_length = utils.bytes_to_int(self.msg[-4:])
+            self.msg_length = utils.bytes_to_uint(self.msg[-4:])
 
         if len(self.msg) == 12:
             macro_cmd_counter = utils.bytes_to_uint(self.msg[-4:])
diff --git a/simulators/acu_status/acu_utils.py b/simulators/acu_status/acu_utils.py
index 4abd82e..8c46654 100644
--- a/simulators/acu_status/acu_utils.py
+++ b/simulators/acu_status/acu_utils.py
@@ -1,8 +1,8 @@
 import time
 from simulators import utils
 
-start_flag = b'\x1D\xFC\xCF\x1A'
-end_flag = b'\xA1\xFC\xCF\xD1'
+start_flag = b'\x1A\xCF\xFC\x1D'
+end_flag = b'\xD1\xCF\xFC\xA1'
 
 
 class ModeCommand(object):
diff --git a/simulators/utils.py b/simulators/utils.py
index b839bd4..20c4ad4 100644
--- a/simulators/utils.py
+++ b/simulators/utils.py
@@ -121,10 +121,10 @@ def int_to_twos(val, n_bytes=4):
     return ("{0:0>%s}" % n_bits).format(binary_string)
 
 
-def binary_to_bytes(binary_string):
+def binary_to_bytes(binary_string, little_endian=True):
     """Convert a binary string in a string of bytes.
 
-    >>> binary_to_bytes('0110100001100101011011000110110001101111')
+    >>> binary_to_bytes('0110100001100101011011000110110001101111', False)
     '\x68\x65\x6C\x6C\x6F'
     """
 
@@ -133,31 +133,37 @@ def binary_to_bytes(binary_string):
     for i in range(0, len(binary_string), 8):
         byte_string += chr(int(binary_string[i:i + 8], 2))
 
-    return byte_string
+    return byte_string[::-1] if little_endian else byte_string
 
 
-def bytes_to_int(byte_string):
+def bytes_to_int(byte_string, little_endian=True):
     """Convert a string of bytes to an integer (like C atoi function).
 
-    >>> bytes_to_int(b'hello')
+    >>> bytes_to_int(b'hello', False)
     448378203247
     """
     binary_string = ''
 
+    if little_endian:
+        byte_string = byte_string[::-1]
+
     for char in byte_string:
         binary_string += bin(ord(char))[2:].zfill(8)
 
     return twos_to_int(binary_string)
 
 
-def bytes_to_uint(byte_string):
+def bytes_to_uint(byte_string, little_endian=True):
     """Convert a string of bytes to an unsigned integer.
 
-    >>> bytes_to_uint(b'hi')
+    >>> bytes_to_uint(b'hi', little_endian=False)
     26729
     """
     binary_string = ''
 
+    if little_endian:
+        byte_string = byte_string[::-1]
+
     for char in byte_string:
         binary_string += bin(ord(char))[2:].zfill(8)
 
@@ -198,32 +204,35 @@ def real_to_binary(num, precision=1):
         )
 
 
-def real_to_bytes(num, precision=1):
+def real_to_bytes(num, precision=1, little_endian=True):
     """Return the bytestring representation of a floating-point number
     (IEEE 754 standard).
 
-    >>> [hex(ord(x)) for x in real_to_bytes(436.56, 1)]
+    >>> [hex(ord(x)) for x in real_to_bytes(436.56, 1, False)]
     ['0x43', '0xda', '0x47', '0xae']
 
-    >>> [hex(ord(x)) for x in real_to_bytes(436.56, 2)]
+    >>> [hex(ord(x)) for x in real_to_bytes(436.56, 2, False)]
     ['0x40', '0x7b', '0x48', '0xf5', '0xc2', '0x8f', '0x5c', '0x29']
     """
 
     binary_number = real_to_binary(num, precision)
-    return binary_to_bytes(binary_number)
+    return binary_to_bytes(binary_number, little_endian=little_endian)
 
 
-def bytes_to_real(bytes_real, precision=1):
+def bytes_to_real(bytes_real, precision=1, little_endian=True):
     """Return the floating-point representation (IEEE 754 standard)
     of bytestring number.
 
-    >>> round(bytes_to_real('\x43\xDA\x47\xAE', 1), 2)
+    >>> round(bytes_to_real('\x43\xDA\x47\xAE', 1, False), 2)
     436.56
 
-    >>> round(bytes_to_real('\x40\x7B\x48\xF5\xC2\x8F\x5C\x29', 2), 2)
+    >>> round(bytes_to_real('\x40\x7B\x48\xF5\xC2\x8F\x5C\x29', 2, False), 2)
     436.56
     """
 
+    if little_endian:
+        bytes_real = bytes_real[::-1]
+
     if precision == 1:
         return struct.unpack('!f', bytes_real)[0]
     elif precision == 2:
@@ -235,20 +244,20 @@ def bytes_to_real(bytes_real, precision=1):
         )
 
 
-def int_to_bytes(val, n_bytes=4):
+def int_to_bytes(val, n_bytes=4, little_endian=True):
     """Return the bytestring representation of a given signed integer.
 
-    >>> [hex(ord(x)) for x in int_to_bytes(354)]
+    >>> [hex(ord(x)) for x in int_to_bytes(354, little_endian=False)]
     ['0x0', '0x0', '0x1', '0x62']
     """
 
-    return binary_to_bytes(int_to_twos(val, n_bytes))
+    return binary_to_bytes(int_to_twos(val, n_bytes), little_endian)
 
 
-def uint_to_bytes(val, n_bytes=4):
+def uint_to_bytes(val, n_bytes=4, little_endian=True):
     """Return the bytestring representation of a given unsigned integer.
 
-    >>> [hex(ord(x)) for x in uint_to_bytes(657)]
+    >>> [hex(ord(x)) for x in uint_to_bytes(657, little_endian=False)]
     ['0x0', '0x0', '0x2', '0x91']
     """
 
@@ -262,7 +271,10 @@ def uint_to_bytes(val, n_bytes=4):
             % (val, min_range, max_range)
         )
 
-    return binary_to_bytes(bin(val)[2:].zfill(n_bytes * 8))
+    return binary_to_bytes(
+        bin(val)[2:].zfill(n_bytes * 8),
+        little_endian=little_endian
+    )
 
 
 def sign(number):

ACU commands and status use little-endian byte order, the current implementation uses big-endian.
diff --git a/tests/test_acu.py b/tests/test_acu.py
index 674856f..f305c94 100644
--- a/tests/test_acu.py
+++ b/tests/test_acu.py
@@ -20,7 +20,7 @@ class TestACU(unittest.TestCase):
 
     def test_status_message_length(self):
         status = self.system.get_message()
-        msg_length = utils.bytes_to_int(status[4:8])
+        msg_length = utils.bytes_to_uint(status[4:8])
         self.assertEqual(msg_length, 813)
 
     def test_duplicated_macro_command_counter(self):
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 86f8db5..6763dbe 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -68,7 +68,7 @@ class TestServer(unittest.TestCase):
     def test_right_binary_to_bytes(self):
         """Convert a binary string into a string of bytes."""
         binary_string = '00000101000110100010100011010010'
-        byte_string = utils.binary_to_bytes(binary_string)
+        byte_string = utils.binary_to_bytes(binary_string, little_endian=False)
         expected_byte_string = b'\x05\x1A\x28\xD2'
         self.assertEqual(byte_string, expected_byte_string)
 
@@ -81,7 +81,7 @@ class TestServer(unittest.TestCase):
     def test_right_bytes_to_int(self):
         """Convert a string of bytes into an integer (like C atoi function)."""
         byte_string = b'\x00\x00\xFA\xFF'
-        result = utils.bytes_to_int(byte_string)
+        result = utils.bytes_to_int(byte_string, little_endian=False)
         expected_result = 64255
         self.assertEqual(result, expected_result)
 
@@ -137,13 +137,13 @@ class TestServer(unittest.TestCase):
     def test_real_to_bytes_single_precision(self):
         """Convert a real number to a string of bytes."""
         number = 45.12371938725634
-        result = utils.real_to_bytes(number)
+        result = utils.real_to_bytes(number, little_endian=False)
         expected_result = b'\x42\x34\x7E\xB0'
         self.assertEqual(result, expected_result)
 
     def test_real_to_bytes_double_precision(self):
         number = 3.14159265358979323846264338327950288419716939937510582097494
-        result = utils.real_to_bytes(number, 2)
+        result = utils.real_to_bytes(number, precision=2, little_endian=False)
         expected_result = b'\x40\x09\x21\xFB\x54\x44\x2D\x18'
         self.assertEqual(result, expected_result)
 
@@ -155,13 +155,17 @@ class TestServer(unittest.TestCase):
     def test_bytes_to_real_single_precision(self):
         """Convert a string of bytes to a floating point  number."""
         byte_string = b'\x42\x34\x7E\xB0'
-        result = utils.bytes_to_real(byte_string)
+        result = utils.bytes_to_real(byte_string, little_endian=False)
         expected_result = 45.12371826171875
         self.assertEqual(result, expected_result)
 
     def test_bytes_to_real_double_precision(self):
         byte_string = b'\x40\x09\x21\xFB\x54\x44\x2D\x18'
-        result = utils.bytes_to_real(byte_string, 2)
+        result = utils.bytes_to_real(
+            byte_string,
+            precision=2,
+            little_endian=False
+        )
         expected_result = (
             3.14159265358979323846264338327950288419716939937510582097494
         )
@@ -175,13 +179,13 @@ class TestServer(unittest.TestCase):
     def test_int_to_bytes_positive(self):
         """Convert a signed integer to a string of bytes."""
         number = 232144
-        result = utils.int_to_bytes(number)
+        result = utils.int_to_bytes(number, little_endian=False)
         expected_result = b'\x00\x03\x8A\xD0'
         self.assertEqual(result, expected_result)
 
     def test_int_to_bytes_negative(self):
         number = -4522764
-        result = utils.int_to_bytes(number)
+        result = utils.int_to_bytes(number, little_endian=False)
         expected_result = b'\xFF\xBA\xFC\xF4'
         self.assertEqual(result, expected_result)
 
@@ -199,7 +203,7 @@ class TestServer(unittest.TestCase):
     def test_uint_to_bytes(self):
         """Convert an unsigned integer to a string of bytes."""
         number = 1284639736
-        result = utils.uint_to_bytes(number)
+        result = utils.uint_to_bytes(number, little_endian=False)
         expected_result = b'\x4C\x92\x0B\xF8'
         self.assertEqual(result, expected_result)
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest numpy>=1.16.0 pandas>=1.0.0
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/discos/simulators.git@8f491d8dda1a217d9233b0f4680e11c52dafaa2a#egg=discos_simulators
exceptiongroup==1.2.2
iniconfig==2.1.0
numpy==2.0.2
packaging==24.2
pandas==2.2.3
pluggy==1.5.0
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
scipy==1.13.1
six==1.17.0
tomli==2.2.1
tzdata==2025.2

name: simulators
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - numpy==2.0.2
      - packaging==24.2
      - pandas==2.2.3
      - pluggy==1.5.0
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - scipy==1.13.1
      - six==1.17.0
      - tomli==2.2.1
      - tzdata==2025.2
prefix: /opt/conda/envs/simulators

tests/test_utils.py::TestServer::test_bytes_to_real_double_precision tests/test_utils.py::TestServer::test_bytes_to_real_single_precision
tests/test_acu.py::TestACU::test_duplicated_macro_command_counter tests/test_acu.py::TestACU::test_mode_command_active tests/test_acu.py::TestACU::test_mode_command_azimuth tests/test_acu.py::TestACU::test_mode_command_drive_to_stow tests/test_acu.py::TestACU::test_mode_command_drive_to_stow_wrong_parameters tests/test_acu.py::TestACU::test_mode_command_elevation tests/test_acu.py::TestACU::test_mode_command_inactive tests/test_acu.py::TestACU::test_mode_command_interlock tests/test_acu.py::TestACU::test_mode_command_preset_absolute tests/test_acu.py::TestACU::test_mode_command_preset_absolute_wrong_parameters tests/test_acu.py::TestACU::test_mode_command_preset_relative tests/test_acu.py::TestACU::test_mode_command_preset_relative_wrong_parameters tests/test_acu.py::TestACU::test_mode_command_program_track tests/test_acu.py::TestACU::test_mode_command_reset tests/test_acu.py::TestACU::test_mode_command_slew tests/test_acu.py::TestACU::test_mode_command_slew_wrong_parameters tests/test_acu.py::TestACU::test_mode_command_slew_zero_speed tests/test_acu.py::TestACU::test_mode_command_stop tests/test_acu.py::TestACU::test_mode_command_stow tests/test_acu.py::TestACU::test_mode_command_stow_wrong_position tests/test_acu.py::TestACU::test_mode_command_unknown_mode_id tests/test_acu.py::TestACU::test_mode_command_unknown_subsystem tests/test_acu.py::TestACU::test_mode_command_unstow tests/test_acu.py::TestACU::test_mode_command_without_activate tests/test_acu.py::TestACU::test_mode_command_wrong_state_active tests/test_acu.py::TestACU::test_multiple_commands_wrong_count tests/test_acu.py::TestACU::test_parse_correct_end_flag tests/test_acu.py::TestACU::test_parse_wrong_end_flag tests/test_acu.py::TestACU::test_parse_wrong_start_flag tests/test_acu.py::TestACU::test_program_track_command_add_entries tests/test_acu.py::TestACU::test_program_track_command_add_entries_empty_table tests/test_acu.py::TestACU::test_program_track_command_add_entries_wrong_start_time tests/test_acu.py::TestACU::test_program_track_command_load_new_table tests/test_acu.py::TestACU::test_program_track_execution tests/test_acu.py::TestACU::test_program_track_out_of_range_rate tests/test_acu.py::TestACU::test_program_track_too_long_sequence tests/test_acu.py::TestACU::test_program_track_too_short_sequence tests/test_acu.py::TestACU::test_program_track_unknown_subsystem tests/test_acu.py::TestACU::test_program_track_wrong_delta_time tests/test_acu.py::TestACU::test_program_track_wrong_first_relative_time tests/test_acu.py::TestACU::test_program_track_wrong_interpolation_mode tests/test_acu.py::TestACU::test_program_track_wrong_load_mode tests/test_acu.py::TestACU::test_program_track_wrong_parameter_id tests/test_acu.py::TestACU::test_program_track_wrong_sequence_length tests/test_acu.py::TestACU::test_program_track_wrong_subsequent_relative_time tests/test_acu.py::TestACU::test_program_track_wrong_tracking_mode tests/test_acu.py::TestACU::test_status_message_length tests/test_acu.py::TestACU::test_unknown_command tests/test_acu.py::TestACU::test_utils_get_command_counter tests/test_utils.py::TestServer::test_day_milliseconds tests/test_utils.py::TestServer::test_int_to_bytes_negative tests/test_utils.py::TestServer::test_int_to_bytes_positive tests/test_utils.py::TestServer::test_int_to_bytes_wrong tests/test_utils.py::TestServer::test_mjd_to_date tests/test_utils.py::TestServer::test_mjd_to_date_old_date tests/test_utils.py::TestServer::test_real_to_binary_double_precision tests/test_utils.py::TestServer::test_real_to_binary_single_precision tests/test_utils.py::TestServer::test_real_to_bytes_double_precision tests/test_utils.py::TestServer::test_real_to_bytes_single_precision tests/test_utils.py::TestServer::test_right_binary_to_bytes tests/test_utils.py::TestServer::test_right_bytes_to_int tests/test_utils.py::TestServer::test_right_bytes_to_uint tests/test_utils.py::TestServer::test_sign_negative tests/test_utils.py::TestServer::test_sign_positive tests/test_utils.py::TestServer::test_sign_zero tests/test_utils.py::TestServer::test_uint_to_bytes tests/test_utils.py::TestServer::test_uint_to_bytes_wrong tests/test_utils.py::TestServer::test_wrong_binary_to_bytes tests/test_utils.py::TestServer::test_wrong_bytes_to_int tests/test_utils.py::TestServer::test_wrong_bytes_to_uint tests/test_utils.py::TestServer::test_wrong_datatype_sign tests/test_utils.py::TestServer::test_wrong_real_to_binary
tests/test_acu.py::TestACU::test_duplicated_command_counter tests/test_acu.py::TestACU::test_utils_macro_command_append tests/test_acu.py::TestACU::test_utils_macro_command_wrong_type_init tests/test_acu.py::TestACU::test_utils_program_track_command_wrong_entry tests/test_acu.py::TestACU::test_utils_program_track_get_empty_table tests/test_utils.py::TestServer::test_binary_complement_longer_mask tests/test_utils.py::TestServer::test_binary_complement_shorter_equal_mask tests/test_utils.py::TestServer::test_bytes_to_real_unknown_precision tests/test_utils.py::TestServer::test_int_to_bytes_out_of_range tests/test_utils.py::TestServer::test_int_to_twos tests/test_utils.py::TestServer::test_mjd_given_date tests/test_utils.py::TestServer::test_mjd_now tests/test_utils.py::TestServer::test_mjd_old_date tests/test_utils.py::TestServer::test_out_of_range_int_to_twos tests/test_utils.py::TestServer::test_real_to_binary_unknown_precision tests/test_utils.py::TestServer::test_real_to_bytes_unknown_precision tests/test_utils.py::TestServer::test_right_binary_complement tests/test_utils.py::TestServer::test_right_checksum tests/test_utils.py::TestServer::test_right_twos_to_int tests/test_utils.py::TestServer::test_uint_to_bytes_out_of_range tests/test_utils.py::TestServer::test_wrong_binary_complement tests/test_utils.py::TestServer::test_wrong_checksum tests/test_utils.py::TestServer::test_wrong_twos_to_int tests/test_utils.py::TestServer::test_wrong_type_binary_complement tests/test_utils.py::TestServer::test_wrong_type_mask_binary_complement
simulators/acu.py simulators/utils.py simulators/acu_status/acu_utils.py simulators/active_surface.py
simulators/acu.py simulators/utils.py simulators/acu_status/acu_utils.py simulators/active_surface.py