public ActionResult Settings(ViewLayoutSettings LayoutSetting) { if (LayoutSetting.LayoutSettingsList != null) { for (int i = 0; i < LayoutSetting.LayoutSettingsList.Count; i++) { LayoutSettings data = db.LayoutSettings.Find(LayoutSetting.LayoutSettingsList[i].ltSId); data.ltSContent = LayoutSetting.LayoutSettingsList[i].ltSContent; db.SaveChanges(); } } if (LayoutSetting.DeviceIO != null) { for (int i = 0; i < LayoutSetting.DeviceIO.Count; i++) { DeviceIO data = db.DeviceIO.Find(LayoutSetting.DeviceIO[i].ioId); data.ioName = LayoutSetting.DeviceIO[i].ioName; data.ioPortName = LayoutSetting.DeviceIO[i].ioPortName; data.ioValType = LayoutSetting.DeviceIO[i].ioValType; db.SaveChanges(); } } return(RedirectToAction("Index")); }
public void TestInit() { var policies = new Policies(); var sub20Interfaces = new Sub20Interfaces(); _s20 = new CSub20(Sub20SerialNumber, sub20Interfaces); II2C i2C = new Sub20I2C(_s20); var gpioConfiguration = new GpioConfiguration(0x00380000, 0x00380000); var gpio = new Sub20Gpio(_s20, gpioConfiguration); gpio.GpioInitialize(); var dutGpio = new DutGpio.DutGpio(null, gpio, new DutGpioBits(16, 17, 18)); var modPres = dutGpio.ModPresentAsserted; Assert.IsTrue(modPres); var deviceIO = new DeviceIO(i2C, dutGpio, policies.PolicyWrap); var cyclops = new Cyclops(deviceIO); var qsfp100GFRS = new Qsfp100G(deviceIO); var maCom = new MaCom(deviceIO); _module = new Module(deviceIO, qsfp100GFRS, cyclops, maCom, policies.PolicyWrap); }
private void SendPacketToDriverForInboundInjection(byte[] packet) { // // Step 1 // Open a synchronous handle to the driver // SafeFileHandle device = null; try { device = DeviceIO.OpenDevice("\\\\.\\IPv6ToBle", false // synchronous ); } catch (Win32Exception e) { Debug.WriteLine("Error opening handle to the driver. " + "Error code: " + e.NativeErrorCode ); return; } // // Step 2 // Send the packet to the driver for it to inject into the inbound // network stack // DeviceIO.SynchronousControl(device, IPv6ToBleIoctl.IOCTL_IPV6_TO_BLE_INJECT_INBOUND_NETWORK_V6 ); }
public DeviceManager() { _myDevice = new DeviceIO(); _keepWorking = true; _myThread = new Thread(DoWork); _myThread.Start(); }
private void CheckForDevice() { Thread.Sleep(this.timeOut); if (!this.myAndroid.HasConnectedDevices) { this.Invoke(new Action(this._Lambda$__86)); this.myAndroid.RefreshDevices(); } else if (this._deviceSerial == null) { this.CheckADBAuthorisation(this.myAndroid); this.myDevice = this.myAndroid.GetConnectedDevice(this.myAndroid.ConnectedDevices[0]); this.Invoke(new Action(this._Lambda$__87)); Thread.Sleep(this.timeOut); this.Invoke(new Action(this._Lambda$__88)); } else { this.CheckADBAuthorisation(this.myAndroid); this.myDevice = this.myAndroid.GetConnectedDevice(this.myAndroid.ConnectedDevices[0]); if (this.myDevice.SerialNumber == this._deviceSerial) { this.Invoke(new Action(this._Lambda$__89)); Thread.Sleep(this.timeOut); this.Invoke(new Action(this._Lambda$__90)); } else { this.Invoke(new Action(this._Lambda$__91)); Thread.Sleep(this.timeOut); this.Invoke(new Action(this._Lambda$__92)); } } }
private void SendListeningRequestToDriver() { // // Step 1 // Open the handle to the driver with Overlapped async I/O flagged // SafeFileHandle device = null; try { device = DeviceIO.OpenDevice("\\\\.\\IPv6ToBle", true); } catch { int code = Marshal.GetLastWin32Error(); DisplayErrorDialog("Could not open a handle to the driver, " + "error code: " + code.ToString() ); return; } lock (numThreadsActiveLock) { NumThreadsActive++; } IAsyncResult result = DeviceIO.BeginGetPacketFromDriverAsync <byte[]>(device, IPv6ToBleIoctl.IOCTL_IPV6_TO_BLE_LISTEN_NETWORK_V6, 1280, IPv6ToBleListenCompletionCallback, null ); }
/// <summary> /// This callback is invoked when one of our previously sent listening /// requests is completed, indicating an async I/O operation has /// finished. /// /// In other words, we should have a packet from the driver if the /// operation was successful. /// /// This method is invoked by the thread pool thread that was waiting /// on the operation. /// </summary> private async void PacketListenCompletionCallback( IAsyncResult result ) { // // Step 1 // Retrieve the async result's...result // byte[] packet; try { packet = DeviceIO.EndGetPacketFromDriverAsync <byte>(result); } catch (Exception e) { Debug.WriteLine("Exception occurred. Source: " + e.Source + " " + "Message: " + e.Message ); return; } // // Step 2 // Send the packet over Bluetooth provided it's not null // if (packet != null) { IPAddress destinationAddress = GetDestinationAddressFromPacket(packet); if (destinationAddress != null) { Debug.WriteLine("Packet received from driver. Packet length: " + packet.Length + ", Destination: " + destinationAddress.ToString() + ", Contents: " + Utilities.BytesToString(packet) ); await SendPacketOverBluetoothLE(packet, destinationAddress ); } } else { Debug.WriteLine("Packet received from driver was null. Some " + "error must have occurred. Nothing to send over " + "BLE." ); return; } // // Step 3 // Send another listening request to the driver to replace this one // Debug.WriteLine($"Sending listening request {++count}"); SendListenRequestToDriver(); }
// GET: GetCredits public IHttpActionResult Getsetioval(int id, string val) { DeviceIO io = db.DeviceIO.Find(id); io.ioValue = val; db.SaveChanges(); return(Ok()); }
public ActionResult SettingsIO(ViewDeviceIO viewlayoutIO) { for (int i = 0; i < viewlayoutIO.DeviceIO.Count; i++) { DeviceIO data = db.DeviceIO.Find(viewlayoutIO.DeviceIO[i].ioId); data.ioName = viewlayoutIO.DeviceIO[i].ioName; data.ioValType = viewlayoutIO.DeviceIO[i].ioValType; } return(RedirectToAction("SettingsIO")); }
public override void Close() { if (this.fileHandle != null) { DeviceIO.CloseHandle(this.fileHandle); this.fileHandle.SetHandleAsInvalid(); this.fileHandle = null; } base.Close(); }
public ulong SeekU(ulong offset, SeekOrigin origin) { ulong n = 0; if (!DeviceIO.SetFilePointerEx(this.fileHandle, offset, out n, (uint)origin)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(n); }
public DeviceFilterEditor(DeviceIO devInst, AndroidControl andInst, string devStorageLoc, int pitBufferSize, bool samsungMode) { base.Load += new EventHandler(this.DeviceFilterEditor_Load); this.AppPath = Application.StartupPath.ToString(); this.InitializeComponent(); this._deviceInstance = devInst; this._androidInstance = andInst; this._devStorageLoc = devStorageLoc; this._pitBufferSize = pitBufferSize; this._samsungMode = samsungMode; }
//[System.Runtime.InteropServices.DllImport("gdi32.dll")] //public static extern bool DeleteObject(IntPtr hObject); public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; _timer.Tick += Timer_Tick; deviceIO = new DeviceIO(); deviceScanner = new DeviceScanner(); deviceScanner.StartListening(); }
public ResultInfo.Result Add(long deviceID, string value, deviceIOType ioType) { DeviceIO endIO = new DeviceIO(); endIO.DeviceID = deviceID; endIO.Valu = value; endIO.IOTypeID = long.Parse(ioType.GetHashCode().ToString()); endIO.TimeStamp = DateTime.Now; db.DeviceIOs.Add(endIO); db.SaveChanges(); return(ResultInfo.GenerateOKResult()); }
public unsafe void Write(byte[] buffer, uint offset, uint count) { uint n = 0; fixed(byte *p = buffer) { if (!DeviceIO.WriteFile(this.fileHandle, p + offset, count, &n, IntPtr.Zero)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } } }
public static APIDeviceIO FromDeviceIO(DeviceIO sourceDeviceIO) { APIDeviceIO result = new APIDeviceIO(); result.ID = sourceDeviceIO.ID; result.DeviceID = long.Parse(sourceDeviceIO.DeviceID.ToString()); result.IOTypeID = long.Parse(sourceDeviceIO.IOTypeID.ToString()); result.Valu = sourceDeviceIO.Valu; result.TimeStamp = DateTime.Parse(sourceDeviceIO.TimeStamp.ToString()); result.ExecTimeStamp = sourceDeviceIO.ExecTimeStamp; result.ScheduleTimeStamp = sourceDeviceIO.ScheduleTimeStamp; return(result); }
public IHttpActionResult GetDevio(string devApi, string devApiKey, string dbioId, string ioValue) { List <Devices> dev = db.Devices.Where(d => d.devApi == devApi && d.devApiKey == devApiKey).ToList(); if (dev.Count == 1) { int id = Convert.ToInt32(dbioId); DeviceIO devio = db.DeviceIO.Find(id); if (devio != null) { devio.ioValue = ioValue; db.SaveChanges(); } } return(Ok()); }
public static Module ModuleFactory(ISub20 sub20, AsyncPolicyWrap policyWrap) { var i2C = new Sub20I2C(sub20); var gpioConfiguration = new GpioConfiguration(0x00380000, 0x00380000); IGpio gpio = new Sub20Gpio(sub20, gpioConfiguration); gpio.GpioInitialize(); var dutGpio = new DutGpio.DutGpio(null, gpio, new DutGpioBits(16, 17, 18)); var deviceIO = new DeviceIO(i2C, dutGpio, policyWrap); var cyclops = new Cyclops.Cyclops(deviceIO); var qsfp100GFRS = new Qsfp100G(deviceIO); var macom = new MaCom.MaCom(deviceIO); var module = new Module(deviceIO, qsfp100GFRS, cyclops, macom, policyWrap); return(module); }
/// <summary> /// Sends IOCTL_IPV6_TO_BLE_ADD_TO_WHITE_LIST to the driver /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private unsafe void Button_4_Add_To_White_List_Click(object sender, RoutedEventArgs e) { // // Step 1 // Open the handle to the driver for synchronous I/O // SafeFileHandle device = null; try { device = DeviceIO.OpenDevice("\\\\.\\IPv6ToBle", false); } catch { int code = Marshal.GetLastWin32Error(); DisplayErrorDialog("Could not open a handle to the driver, " + "error code: " + code.ToString() ); return; } // // Step 2 // Send the supplied IPv6 address for the white list to the driver // to add it to the list // // Hard-coded for testing, would normally acquire from an // authenticated service or other source String whiteListAddress = "fe80::b826:1c8b:ccbb:32f0%11"; // Send the IOCTL bool result = DeviceIO.SynchronousControl(device, IPv6ToBleIoctl.IOCTL_IPV6_TO_BLE_ADD_TO_WHITE_LIST, whiteListAddress); if (!result) { int error = Marshal.GetLastWin32Error(); DisplayErrorDialog("Adding to white list failed with this " + "error code: " + error.ToString()); } }
/// <summary> /// Sends IOCTL_IPV6_TO_BLE_REMOVE_FROM_MESH_LIST to the driver /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private unsafe void Button_7_Remove_From_Mesh_List_Click(object sender, RoutedEventArgs e) { // // Step 1 // Open the handle to the driver for synchronous I/O // SafeFileHandle device = null; try { device = DeviceIO.OpenDevice("\\\\.\\IPv6ToBle", false); } catch { int code = Marshal.GetLastWin32Error(); DisplayErrorDialog("Could not open a handle to the driver, " + "error code: " + code.ToString() ); return; } // // Step 2 // Send the supplied IPv6 address for the white list to the driver // to add it to the list // // Hard-coded for testing, would normally acquire from an // authenticated service or other source String meshListAddress = "fe80::3ff8:d2ff:feeb:27b8%2"; // Send the IOCTL bool result = DeviceIO.SynchronousControl(device, IPv6ToBleIoctl.IOCTL_IPV6_TO_BLE_REMOVE_FROM_MESH_LIST, meshListAddress); if (!result) { int error = Marshal.GetLastWin32Error(); DisplayErrorDialog("Removing from mesh list failed with this " + "error code: " + error.ToString()); } }
public ResultInfo.Result Add(long deviceID, string value, deviceIOType ioType, DateTime executionTime) { try { DeviceIO endIO = new DeviceIO(); endIO.DeviceID = deviceID; endIO.Valu = value; endIO.IOTypeID = long.Parse(ioType.GetHashCode().ToString()); endIO.TimeStamp = DateTime.Now; endIO.ExecTimeStamp = executionTime; db.DeviceIOs.Add(endIO); db.SaveChanges(); return(ResultInfo.GenerateOKResult("Saved", endIO.ID)); } catch { return(ResultInfo.GetResultByID(1)); } }
public DeviceFilterEditor(string fileName, DeviceIO devInst, AndroidControl andInst, string devStorageLoc, int pitBufferSize, bool samsungMode) { base.Load += new EventHandler(this.DeviceFilterEditor_Load); this.AppPath = Application.StartupPath.ToString(); this.InitializeComponent(); this._deviceInstance = devInst; this._androidInstance = andInst; this._devStorageLoc = devStorageLoc; this._pitBufferSize = pitBufferSize; this._samsungMode = samsungMode; if (!string.IsNullOrEmpty(fileName)) { this.txtFileName.Text = Path.GetFileName(fileName); this.LoadFile(fileName); } else { this.Close(); } }
/// <summary> /// Sends IOCTL_IPV6_TO_BLE_PURGE_MESH_LIST to the driver /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private unsafe void Button_9_Purge_Mesh_List_Click(object sender, RoutedEventArgs e) { // // Step 1 // Open the handle to the driver for synchronous I/O // SafeFileHandle device = null; try { device = DeviceIO.OpenDevice("\\\\.\\IPv6ToBle", false); } catch { int code = Marshal.GetLastWin32Error(); DisplayErrorDialog("Could not open a handle to the driver, " + "error code: " + code.ToString() ); return; } // // Step 2 // Send the supplied IPv6 address for the white list to the driver // to add it to the list // // Send the IOCTL bool result = DeviceIO.SynchronousControl(device, IPv6ToBleIoctl.IOCTL_IPV6_TO_BLE_PURGE_MESH_LIST); if (!result) { int error = Marshal.GetLastWin32Error(); DisplayErrorDialog("Purging mesh list failed with this " + "error code: " + error.ToString()); } }
private void SendListenRequestToDriver() { // // Step 1 // Open an async handle to the driver // SafeFileHandle device = null; try { device = DeviceIO.OpenDevice("\\\\.\\IPv6ToBle", true // async ); } catch (Win32Exception e) { Debug.WriteLine("Error opening handle to the driver. " + "Error code: " + e.NativeErrorCode ); return; } // // Step 2 // Begin an asynchronous operation to get a packet from the driver // IAsyncResult listenResult = DeviceIO.BeginGetPacketFromDriverAsync <byte[]>( device, IPv6ToBleIoctl.IOCTL_IPV6_TO_BLE_LISTEN_NETWORK_V6, 1280, // 1280 bytes max PacketListenCompletionCallback, null // no specific state to track ); if (listenResult == null) { Debug.WriteLine("Invalid request to listen for a packet."); } }
public static void Demo() { String filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), @"FilterOpLock.dat"); // Attempt to open/create the file for processing (must be asynchronous) using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 8096, FileOptions.Asynchronous)) { m_device = new DeviceIO(fs.SafeFileHandle, true); Byte[] data = Encoding.ASCII.GetBytes("This is some text in the FilterOpLock file"); fs.Write(data, 0, data.Length); // Request the Filter Oplock on the file. // When another process attempts to access the file, the system will // 1. Block the other process until we close the file // 2. Call us back notifying us that another process wants to access the file BeginFilter( delegate(IAsyncResult result) { EndFilter(result); Console.WriteLine("Another process wants to access the file or the file closed"); Thread.VolatileWrite(ref s_endEarly, 1); // Tell Main thread to end early }, null); // Pretend we're accessing the file here for (Int32 count = 0; count < 1000; count++) { Console.WriteLine("Accessing the file ({0})...", count); // If the user hits a key or if another application wants to access the file, // close the file. if (Console.KeyAvailable || (Thread.VolatileRead(ref s_endEarly) == 1)) break; Thread.Sleep(150); } } // Close the file here allows the other process to continue running Console.WriteLine("The file is closed."); Console.ReadLine(); File.Delete(filename); }
private SafeFileHandle openFile(string id, FileAccess desiredAccess) { uint access; switch (desiredAccess) { case FileAccess.Read: access = DeviceIO.GENERIC_READ; break; case FileAccess.Write: access = DeviceIO.GENERIC_WRITE; break; case FileAccess.ReadWrite: access = DeviceIO.GENERIC_READ | DeviceIO.GENERIC_WRITE; break; default: access = DeviceIO.GENERIC_READ; break; } SafeFileHandle ptr = DeviceIO.CreateFile( id, access, DeviceIO.FILE_SHARE_READ, IntPtr.Zero, DeviceIO.OPEN_EXISTING, DeviceIO.FILE_FLAG_NO_BUFFERING | DeviceIO.FILE_FLAG_WRITE_THROUGH, IntPtr.Zero); if (ptr.IsInvalid) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(ptr); }
public ActionResult Create(ViewLayout ViewdevLayout) { if (ModelState.IsValid) { ViewdevLayout.Devlayout.dvLtVersion = "1"; ViewdevLayout.Devlayout.dvLtLastUpdate = DateTime.Now.ToString(); if (ViewdevLayout.Devlayout.dvLtType == 1) { db.DevLayout.Add(ViewdevLayout.Devlayout); db.SaveChanges(); if (ViewdevLayout.result != null) { string[] sett = ViewdevLayout.result.Split('#'); foreach (string s in sett) { if (s != "") { LayoutSettings layouteset = new LayoutSettings(); string[] data = s.Split(';'); foreach (string v in data) { string[] val = v.Split(':'); if (val[0] == "type") { layouteset.ltSType = val[1]; } else if (val[0] == "left") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "top") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "width") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "height") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } } layouteset.ltSDevLayoutId = ViewdevLayout.Devlayout.dvLtAutoId; db.LayoutSettings.Add(layouteset); db.SaveChanges(); } } string subPath = ViewdevLayout.Devlayout.dvLtAutoId.ToString(); System.IO.Directory.CreateDirectory(Server.MapPath("~/files/" + subPath)); } DeviceIO addnew; for (int i = 0; i < ViewdevLayout.inputCount; i++) { addnew = new DeviceIO { ioType = "1", ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, ioValType = "bit" }; db.DeviceIO.Add(addnew); } for (int i = 0; i < ViewdevLayout.outputCount; i++) { addnew = new DeviceIO { ioType = "2", ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, ioValType = "bit" }; db.DeviceIO.Add(addnew); } for (int i = 0; i < ViewdevLayout.virtualCount; i++) { addnew = new DeviceIO { ioType = "3", ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, ioValType = "string" }; db.DeviceIO.Add(addnew); } db.SaveChanges(); return(RedirectToAction("Settings", new { id = ViewdevLayout.Devlayout.dvLtAutoId })); } else if (ViewdevLayout.Devlayout.dvLtType == 2) { string[] sett = ViewdevLayout.result.Split('#'); db.DevLayout.Add(ViewdevLayout.Devlayout); db.SaveChanges(); foreach (string s in sett) { if (s != "") { LayoutSettings layouteset = new LayoutSettings(); string[] data = s.Split(';'); foreach (string v in data) { string[] val = v.Split(':'); if (val[0] == "type") { layouteset.ltSType = val[1]; } else if (val[0] == "left") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "top") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "width") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "height") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } } layouteset.ltSDevLayoutId = ViewdevLayout.Devlayout.dvLtAutoId; db.LayoutSettings.Add(layouteset); db.SaveChanges(); } } string subPath = ViewdevLayout.Devlayout.dvLtAutoId.ToString(); System.IO.Directory.CreateDirectory(Server.MapPath("~/files/" + subPath)); return(RedirectToAction("Settings", new { id = ViewdevLayout.Devlayout.dvLtAutoId })); } else if (ViewdevLayout.Devlayout.dvLtType == 3) { db.DevLayout.Add(ViewdevLayout.Devlayout); db.SaveChanges(); DeviceIO addnew; for (int i = 0; i < ViewdevLayout.inputCount; i++) { addnew = new DeviceIO { ioType = "1", ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, ioValType = "bit" }; db.DeviceIO.Add(addnew); } for (int i = 0; i < ViewdevLayout.outputCount; i++) { addnew = new DeviceIO { ioType = "2", ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, ioValType = "bit" }; db.DeviceIO.Add(addnew); } for (int i = 0; i < ViewdevLayout.virtualCount; i++) { addnew = new DeviceIO { ioType = "3", ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, ioValType = "string" }; db.DeviceIO.Add(addnew); } db.SaveChanges(); return(RedirectToAction("Settings", new { id = ViewdevLayout.Devlayout.dvLtAutoId })); } } return(View(ViewdevLayout)); }
/// <summary> /// Delegate callback function for handling asynchronous I/O /// completion events. /// /// For more info on this function, see /// https://msdn.microsoft.com/library/system.threading.iocompletioncallback /// </summary> private void IPv6ToBleListenCompletionCallback( IAsyncResult result ) { lock (numThreadsActiveLock) { NumThreadsActive--; } // // Step 1 // Retrieve the async result's...result // byte[] packet = null; try { packet = DeviceIO.EndGetPacketFromDriverAsync <byte[]>(result); } catch (Exception e) { Debug.WriteLine("Exception occurred." + e.Message); return; } // // Step 2 // Send the packet over Bluetooth provided it's not null // if (packet != null) { numPacketsReceived++; //Debug.WriteLine($"Received packet {numPacketsReceived}" + // $" from the driver." // ); } else { Debug.WriteLine("Packet was null."); return; } // // Compress the packet (test) // //Debug.WriteLine("Original packet size: " + packet.Length); //Debug.WriteLine("Original packet contents: " + Utilities.BytesToString(packet)); //Debug.WriteLine("Compressing packet..."); //HeaderCompression compression = new HeaderCompression(); //int processedHeaderLength = 0; //int payloadLength = 0; //byte[] compressedPacket = compression.CompressHeaderIphc(packet, // out processedHeaderLength, // out payloadLength // ); //Debug.WriteLine("Compression of packet complete."); //if(compressedPacket == null) //{ // Debug.WriteLine("Error occurred during packet compression. " + // "Unable to compress." // ); //} //else //{ // Debug.WriteLine("Compressed packet size: " + compressedPacket.Length); // Debug.WriteLine("Compressed packet contents: " + Utilities.BytesToString(compressedPacket)); //} //// //// Decompress the compressed packet back into its original form (test) //// //Debug.WriteLine("Decompressing packet..."); //byte[] uncompressedPacket = compression.UncompressHeaderIphc(compressedPacket, // processedHeaderLength, // payloadLength // ); //if (uncompressedPacket == null) //{ // Debug.WriteLine("Error occurred during packet decompression."); //} //else //{ // Debug.WriteLine("Uncompressed packet size: " + uncompressedPacket.Length); // Debug.WriteLine("Uncompressed packet contents: " + Utilities.BytesToString(uncompressedPacket)); // Debug.WriteLine("Decompressed packet size is same as original: " + (packet.Length == uncompressedPacket.Length)); // Debug.WriteLine("Decompressed packet is identical to the original: " + (Utilities.PacketsEqual(packet, uncompressedPacket))); //} // Test: Send another listening request to the driver. Comment out // if sending a fixed number in the first place; uncomment if // sending and testing an arbitrarily large number of packets. //if (isTesting) //{ // SendListeningRequestToDriver(); //} }
private void Button_11_query_mesh_role_Click(object sender, RoutedEventArgs e) { // // Step 1 // Open the handle to the driver for synchronous I/O // SafeFileHandle device = null; try { device = DeviceIO.OpenDevice("\\\\.\\IPv6ToBle", false); } catch { int code = Marshal.GetLastWin32Error(); DisplayErrorDialog("Could not open a handle to the driver, " + "error code: " + code.ToString() ); return; } // // Step 2 // Ask the driver what this device's role is // Send the IOCTL bool isBorderRouter = false; bool result = false; try { result = DeviceIO.SynchronousControl(device, IPv6ToBleIoctl.IOCTL_IPV6_TO_BLE_QUERY_MESH_ROLE, out isBorderRouter ); } catch (Exception ex) { Debug.WriteLine(ex.Message); } if (!result) { int error = Marshal.GetLastWin32Error(); DisplayErrorDialog("Querying driver for mesh role failed " + "with this error code: " + error.ToString() ); } else { // The operation succeeded, now check the role if (isBorderRouter) { DisplayErrorDialog("This device is a border router."); } else { DisplayErrorDialog("This device is not a border router."); } } }
private bool FileExists(string _path) { DeviceIO device = new DeviceIO(); return(device.FileExists(_path)); }
private static void LCDBrightnessForMsdnMagazine() { DeviceControlCode s_SetBrightness = new DeviceControlCode(DeviceType.Video, 0x127, DeviceMethod.Buffered, DeviceAccess.Any); using (DeviceIO lcd = new DeviceIO(@"\\.\LCD", FileAccess.ReadWrite, FileShare.ReadWrite, false)) { for (Int32 times = 0; times < 10; times++) { for (Int32 dim = 0; dim <= 100; dim += 20) { Win32DisplayBrightnessStructure db = new Win32DisplayBrightnessStructure(Win32DisplayBrightnessStructure.DisplayPowerFlags.ACDC, (Byte)((times % 2 == 0) ? dim : 100 - dim)); lcd.Control(s_SetBrightness, db); Thread.Sleep(150); } } } }
// GET: GetCredits public string Getgetioval(int id) { DeviceIO io = db.DeviceIO.Find(id); return(io.ioValue.ToString()); }