private void _FrameProcessor(EtaConnectionFrames.CFrame frame) { EFrameCommand _command = (EFrameCommand)frame.Command; byte[] _bytes_buffer = frame.BytesFrame; int _buffer_length = _bytes_buffer.Length; //Console.WriteLine(BitConverter.ToString(_bytes_buffer)); if (_command == EFrameCommand.DEBUG_STRING) { Console.Write(Encoding.GetEncoding(1251).GetString(_bytes_buffer)); } else if (_command == EFrameCommand.STATUS) { int _offset = 0; bool _is_new_hall = false, _is_new_pwm = false; HallPosition = _bytes_buffer[_offset++]; byte _new_hall_prescaler = _bytes_buffer[_offset++]; ushort _new_hall_period = BitConverter.ToUInt16(_bytes_buffer, _offset); _offset += 2; ushort _new_pwm_power = BitConverter.ToUInt16(_bytes_buffer, _offset); _offset += 2; _is_new_hall = _new_hall_prescaler != _hall_prescaler || _new_hall_period != _hall_period; _is_new_pwm = _new_pwm_power != _pwm_power; HallPrescaler = _new_hall_prescaler; HallPeriod = _new_hall_period; PWMPower = _new_pwm_power; if (_is_new_hall) { OnPropertyChanged(nameof(NewParamHall)); } if (_is_new_pwm) { OnPropertyChanged(nameof(NewParamPWM)); } } }
private void _AsyncFrameProcessor(byte frame_command, byte[] frame_data) { EFrameCommand _command = (EFrameCommand)frame_command; int _frame_data_length = frame_data.Length, _offset = 0; //Console.WriteLine(BitConverter.ToString(_bytes_buffer)); if (_command == EFrameCommand.DebugString) { Console.Write(Encoding.GetEncoding(1251).GetString(frame_data)); } }
public byte[] RequestFrame(EFrameCommand frame_command, byte[] frame_data, int timeout_ms) { EtaConnectionFrames _connection_frames_temp = d_connection_frames; return(_connection_frames_temp?.RequestFrame((byte)frame_command, frame_data, timeout_ms)); }
public void PushFrame(EFrameCommand frame_command, byte[] frame_data) { EtaConnectionFrames _connection_frames_temp = d_connection_frames; _connection_frames_temp?.PushAsyncFrame((byte)frame_command, frame_data); }