private void open_handle() { handle = AardvarkApi.aa_open(port); if (handle <= 0) { Console.WriteLine("Unable to open Aardvark device on port {0}", port); Console.WriteLine("error: {0}", AardvarkApi.aa_status_string(handle)); } }
public int i2c_read(ushort slave_addr, ushort bytes, out byte[] data_in) { data_in = Enumerable.Repeat <byte>(0, bytes).ToArray(); //set it to all 0's first var result = AardvarkApi.aa_i2c_read(handle, slave_addr, AardvarkI2cFlags.AA_I2C_NO_FLAGS, bytes, data_in); if (result < 0) { Console.WriteLine("error: {0}\n", AardvarkApi.aa_status_string(result)); } return(result); }
public int i2c_write(ushort slave_addr, ushort num_bytes, byte[] data_out) { var result = AardvarkApi.aa_i2c_write(handle, slave_addr, AardvarkI2cFlags.AA_I2C_NO_FLAGS, num_bytes, data_out); if (result < 0) { Console.WriteLine("error: {0}\n", AardvarkApi.aa_status_string(result)); //setup_aardvark(); result = AardvarkApi.aa_i2c_write(handle, slave_addr, AardvarkI2cFlags.AA_I2C_NO_FLAGS, num_bytes, data_out); if (result < 0) { return(-1); } } return(result); }