static void Main(string[] args) { var data = new RadioEightChannelsData(); data.Throttle = 0; data.Yaw = 32; data.Pitch = 64; data.Roll = 128; data.Aux1 = 32; data.Aux2 = 64; data.Aux3 = 128; data.Aux4 = 255; using (var port = new SerialCommunicator("com7", 9600)) { for (int i = 0; i < 10000000; ++i) { data.Throttle = Convert.ToByte((data.Throttle + 1) % 255); data.Yaw = Convert.ToByte((data.Yaw + 1) % 255); data.Pitch = Convert.ToByte((data.Pitch + 1) % 255); data.Roll = Convert.ToByte((data.Roll + 1) % 255); //data.Aux1 = Convert.ToByte((data.Aux1 + 1) % 255); //data.Aux2 = Convert.ToByte((data.Aux2 + 1) % 255); //data.Aux3 = Convert.ToByte((data.Aux3 + 1) % 255); //data.Aux4 = Convert.ToByte((data.Aux4 + 1) % 255); port.SendData(data.toBytes()); } } }
// Use this for initialization void Awake() { image = GetComponent <Image>(); serial = gyroscope.GetComponent <SerialCommunicator>(); serial.OnArduinoConnected += OnArduinoConnected; serial.OnArduinoConnectionFailed += OnArduinoConnectionFailed; }
static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Console(LogEventLevel.Verbose) .CreateLogger(); using var communicator = new SerialCommunicator(); using var amp = new CambridgeCX81(communicator, Log.Logger); if (args?.Length > 0) { HandleCommands(communicator, amp, args); if (args.Contains("--wait")) { string q; do { q = Console.ReadLine(); }while (q != "q"); } } else { string s = Console.ReadLine(); while (!string.IsNullOrEmpty(s)) { HandleCommands(communicator, amp, s.Split(" ")); s = Console.ReadLine(); } } Console.WriteLine("Done!"); }
void Start() { rigidBody = GetComponent <Rigidbody> (); health = GetComponent <PlayerHealth> (); serial = GetComponent <SerialCommunicator> (); screenShake = GetComponent <Transform>().Find("PlayerCamera").GetComponent <ScreenShake> (); fuel = maxFuel / 2; resource = 0; }
public DeskController() { _communicator = new SerialCommunicator("PSDESK"); var controllerThread = new Thread(ControllerThreadStart) {IsBackground = true}; controllerThread.Start(); var heartbeatThread = new Thread(HeartbeatThreadStart) {IsBackground = true}; heartbeatThread.Start(); }
public MainWindow() { InitializeComponent(); sc = new SerialCommunicator(); List <SerialPortInfo> portInfos = sc.getPortNames(); SerialPortInfo arduinoPort = portInfos.FirstOrDefault(p => p.Name.Contains("Arduino")); if (arduinoPort != null) { //sc.connect(this, receive, arduinoPort.Name, 9600); } }
/// <summary> /// Disconnect and retry the connecting to the SenseGlove, /// such as when a different glove is connected or when the (manual) connection is lost. /// </summary> public void RetryConnection() { this.Disconnect(); if (this.connectionMethod != ConnectionMethod.HardCoded) { if (!SenseGloveCs.DeviceScanner.IsScanning()) { SenseGloveCs.DeviceScanner.pingTime = 200; SenseGloveCs.DeviceScanner.scanDelay = 500; SenseGloveCs.DeviceScanner.StartScanning(true); } } else //we're dealing with a custom connection! { if (canReport) { SenseGlove_Debugger.Log("Attempting to connect to " + this.address); } Communicator PCB = null; if (this.address.Contains("COM")) //Serial connections { if (this.address.Length > 4 && this.address.Length < 6) { this.address = "\\\\.\\" + this.address; } PCB = new SerialCommunicator(this.address); } if (PCB != null) { PCB.Connect(); if (PCB.IsConnected()) { this.glove = new SenseGlove(PCB); this.glove.OnFingerCalibrationFinished += Glove_OnFingerCalibrationFinished; } else if (canReport) { SenseGlove_Debugger.Log("ERROR: Could not connect to " + this.address); canReport = false; } } else if (canReport) { SenseGlove_Debugger.Log("ERROR: " + this.address + " is not a valid address."); canReport = false; } } this.elapsedTime = 0; this.standBy = false; }
public Form1() { InitializeComponent(); sCom1 = new SerialCommunicator(); portInfos = sCom1.GetPortNames(); portComboBox.Items.Clear(); portComboBox.Items.AddRange(portInfos); SerialPortInfo arduinoPort = portInfos.FirstOrDefault(p => p.Name.Contains("Arduino")); if (arduinoPort != null) { portComboBox.SelectedItem = arduinoPort; } UpdateGui(); }
private void SetUpPort() { _serialPort = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One); _communicator = new SerialCommunicator(_serialPort); _communicator.Receiver.OnProcessMessage += ProcessMessage; }
void Start() { playerHealth = maxPlayerHealth; flightControl = GetComponent <FlightControl> (); serial = GetComponent <SerialCommunicator> (); }
void Awake() { serial = GetComponent <SerialCommunicator>(); serial.OnGyroscopeData += OnGyroscopeData; }
public ViewModelWorker() { Serial = new SerialCommunicator(); }