How to use the minimalmodbus._floatToBytestring function in minimalmodbus

To help you get started, we’ve selected a few minimalmodbus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyhys / minimalmodbus / test / test_minimalmodbus.py View on Github external
def testWrongInputType(self):
        for value in _NOT_NUMERICALS:
            self.assertRaises(TypeError, minimalmodbus._floatToBytestring, value, 2)
        for value in _NOT_INTERGERS:
            self.assertRaises(TypeError, minimalmodbus._floatToBytestring, 1.1,   value)
github pyhys / minimalmodbus / test / test_minimalmodbus.py View on Github external
def testSanity(self):
        for value, numberOfRegisters, knownstring in self.knownValues:
            resultvalue = minimalmodbus._bytestringToFloat( \
                minimalmodbus._floatToBytestring(value, numberOfRegisters), numberOfRegisters)
            self.assertAlmostEqualRatio(resultvalue, value)
github pyhys / minimalmodbus / test / test_minimalmodbus.py View on Github external
def testKnownValues(self):
        for value, numberOfRegisters, knownstring in self.knownValues:
            resultstring = minimalmodbus._floatToBytestring(value, numberOfRegisters)
            self.assertEqual(resultstring, knownstring)
        self.assertEqual(minimalmodbus._floatToBytestring(1.5e999, 2), '\x7f\x80\x00\x00') # +inf
github pyhys / minimalmodbus / test / test_minimalmodbus.py View on Github external
def testKnownValues(self):
        for value, numberOfRegisters, knownstring in self.knownValues:
            resultstring = minimalmodbus._floatToBytestring(value, numberOfRegisters)
            self.assertEqual(resultstring, knownstring)
        self.assertEqual(minimalmodbus._floatToBytestring(1.5e999, 2), '\x7f\x80\x00\x00') # +inf