public static List hex_string_to_list(string hexString) { if (hexString == null) { return(null); } if (hexString.Length == 0) { return(new List()); } if (hexString.Length % 2 != 0) { throw new ArgumentException("The hex string cannot have an odd number of digits."); } var buffer = new byte[hexString.Length / 2]; for (var i = 0; i < buffer.Length; i++) { var byteValue = hexString.Substring(i * 2, 2); buffer[i] = byte.Parse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture); } return(PythonConvert.ToPythonList(buffer)); }
public List read(string bus_id, int device_address, int count) { var buffer = new byte[count]; _i2CBusService.Read(bus_id, device_address, buffer.AsArraySegment()); return(PythonConvert.ToPythonList(buffer)); }
public static List to_list(object value) { if (value is IEnumerable enumerable) { PythonConvert.ToPythonList(enumerable); } return(new List { PythonConvert.ToPython(value) }); }
public List write_read(string bus_id, int device_address, List write_buffer, int read_buffer_length) { var readBuffer = new byte[read_buffer_length]; _i2CBusService.WriteRead( bus_id, device_address, ConverterPythonProxy.ListToByteArray(write_buffer).AsArraySegment(), readBuffer.AsArraySegment()); return(PythonConvert.ToPythonList(readBuffer)); }
public static List ulong_to_list(ulong buffer, int length) { return(PythonConvert.ToPythonList(ULongToArray(buffer, length))); }
public List get_ssdp_devices() { var devices = _discoveryService.GetDiscoveredDevices().Select(ToPythonDictionary); return(PythonConvert.ToPythonList(devices)); }