public void SendDataRequest(CommandEnum command, ModulationEnum modulation, bool FEC, byte[] data) { if (data == null || data.Length == 0) { return; } byte[] buffer = new byte[data.Length + 1]; byte configuration = 0x01; switch (modulation) { case ModulationEnum.B_PSK: configuration = 0x00; break; case ModulationEnum.Q_PSK: configuration <<= 4; // 0001 0000 break; case ModulationEnum.EIGHT_PSK: configuration <<= 5; // 0010 0000 break; case ModulationEnum.BPSK_WITH_PNA: configuration = 0x70; // 0111 0000 break; } if (FEC) { configuration |= 0x40; // 0100 0000 } buffer[0] = configuration; for (int i = 0; i < data.Length; ++i) { buffer[i + 1] = data[i]; } byte[] frame = null; switch (command) { case CommandEnum.DL_DATA_REQUEST: frame = MakeFrame(0x50, buffer); break; case CommandEnum.PHY_DATA_REQUEST: frame = MakeFrame(0x24, buffer); break; } SendFrame(frame); }
private void SendClicked(object sender, RoutedEventArgs e) { if (serialLayer.serialPort.IsOpen) { int len = ASCIITextBox.Text.Length; if (len > 0) { byte[] data = new byte[len]; string msg = ASCIITextBox.Text; for (int i = 0; i < len; ++i) { data[i] = (byte)msg[i]; } CommandEnum cmd = CommandEnum.DL_DATA_REQUEST; if ((bool)PHYRadioButton.IsChecked) { cmd = CommandEnum.PHY_DATA_REQUEST; } ModulationEnum mod = ModulationEnum.B_PSK; if ((bool)QPSKRadioButton.IsChecked) { mod = ModulationEnum.Q_PSK; } else if ((bool)EIGHTPSKRadioButton.IsChecked) { mod = ModulationEnum.EIGHT_PSK; } else if ((bool)BPSKPNARadioButton.IsChecked) { mod = ModulationEnum.BPSK_WITH_PNA; } serialLayer.SendDataRequest(cmd, mod, (bool)FECCheckBox.IsChecked, data); } } }