Eddy5 Posted October 22, 2008 Share Posted October 22, 2008 I'm trying to write a small app to read and log data from a weather station connected over USB (Oregon Scientific RMS300 which uses the WMR100 protocol). Is there a way in AutoIt to read data packets from such a USB device? Link to comment Share on other sites More sharing options...
martin Posted October 22, 2008 Share Posted October 22, 2008 I'm trying to write a small app to read and log data from a weather station connected over USB (Oregon Scientific RMS300 which uses the WMR100 protocol).Is there a way in AutoIt to read data packets from such a USB device?AFAIK only if the usb driver simulates a serial port and surprisingly maybe, many pieces of equipment do just that. So unplug the device and look in Device Manager and see what Communication ports you have .(Probably Com1 and Com2.) Plug the device in and have another look at what com ports there are. If another one has appeared you are in luck, otherwise I am afraid I have no idea. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ptrex Posted October 22, 2008 Share Posted October 22, 2008 (edited) @Eddy5This is the API's you need Read / Write USB devicesand this one More API'sSo far the theory.regardsptrex Edited October 22, 2008 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
martin Posted October 22, 2008 Share Posted October 22, 2008 @Eddy5This is the API's you need Read / Write USB devicesand this one More API'sSo far the theory.regardsptrexWow, great link, thanks ptrex. When I read articles like that I just know I can take over the world. (I just need a liiiittle bit more time.) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Eddy5 Posted October 22, 2008 Author Share Posted October 22, 2008 Thanks for the info guys. It's definitely a USB HID device so I'll have to get reading up on it. Link to comment Share on other sites More sharing options...
Eddy5 Posted October 23, 2008 Author Share Posted October 23, 2008 (edited) I've found a DLL that sound do the trickhttp://www.codeproject.com/KB/cs/USB_HID.aspxand herehttp://groups.google.com/group/usb_net/bro...a665ed504bfc697The zip file contains the DLL and an EXE that is capable of reading the data from the weather station so I'm pretty sure this is the DLL to use.Now I just need to work out how to use the DLL in AutoIt.Here's some of the code (C I think) from the applicationthis.usb.ProductId = 51713; this.usb.VendorId = 4062; this.usb.Shared = usbShared; this.usb.OnSpecifiedDeviceRemoved += new System.EventHandler(this.usb_OnSpecifiedDeviceRemoved); this.usb.OnDeviceArrived += new System.EventHandler(this.usb_OnDeviceArrived); this.usb.OnDeviceRemoved += new System.EventHandler(this.usb_OnDeviceRemoved); this.usb.OnDataRecieved += new UsbLibrary.DataRecievedEventHandler(this.usb_OnDataRecieved); this.usb.OnSpecifiedDeviceArrived += new System.EventHandler(this.usb_OnSpecifiedDeviceArrived); this.usb.OnDataSend += new System.EventHandler(this.usb_OnDataSend); usbBuffer = new byte[256]; workingBuffer = new byte[256]; usbRecord = new byte[10][]; for (int i = 0; i < usbRecord.Length; i++) { usbRecord[i] = new byte[i + 128]; }private void usb_OnDataRecieved(object sender, DataRecievedEventArgs args) { if (InvokeRequired) { try { Invoke(new DataRecievedEventHandler(usb_OnDataRecieved), new object[] { sender, args }); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } else { string rec_data = ""; foreach (byte myData in args.data) { if (myData.ToString("x").Length == 1) { rec_data += "0"; } rec_data += myData.ToString("x") + " "; } Array.Copy(args.data, 2, usbBuffer, myBufferPos, (int)args.data[1]); myBufferPos += (int)args.data[1]; // to remove 1st byte this.lb_read.Items.Add(rec_data.Substring(3)); } } Edited October 23, 2008 by Eddy5 Link to comment Share on other sites More sharing options...
Eddy5 Posted October 23, 2008 Author Share Posted October 23, 2008 I'm getting a bit stuck with this. Not really sure what I'm doing to be honest. If anyone has any advice on the AutoIt commands to get me going (i.e. how do I actually get AutoIt to get anything meaningful from the USBLibrary.dll or HID.dll) I'd be very grateful. Link to comment Share on other sites More sharing options...
ptrex Posted October 23, 2008 Share Posted October 23, 2008 @martin You are welcome. I am curious to see with what you come up with. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now