Reading from USB device and sending queries to it, in C# - c#

I've read this: https://stackoverflow.com/questions/1176053/, which was an insightful article.
However, I have no great background in WMI, and I found the large amount of documentation to be overwhelming. I can't find what I'm looking for.
The situation is that I have a device that will send data over the USB port, to the soundcard of the PC in question.
Consider camera-software. You connect your camera, start the program, and you can control the program with the camera, and vica versa. For instance, you can press a button on the camera and it'll start transmitting to the program. Or you can click a button in the program and it will start querying for data.
I need to find a way to query and catch this data, safely and correct.
It's probably a Stream of bytes, but searching for that doesn't produce any results.
I'm thinking I first need to somehow connect.
Then send the query.
Then receive.
However, connecting and querying both is something that I can't find in the example code, or the System.Management documentation on MSDN.

I don't think that WMI code would be relevant for you, I think that's just able to get out basic information about the device. If you want to actually read and send data to it you'll have to use different APIs.
When I've done any USB develoment it's been mostly using HID which is fairly straightforward, but I don't think you can transfer audio streams using HID, you'll need to use the Audio class driver. Though you might need to use HID to find out information about the soundcard.
Some useful links to get you started are:
Jan Axelson's website (author of USB Complete) - http://janaxelson.com/usbc.htm
A USB HID Component for C# - http://www.codeproject.com/KB/cs/USB_HID.aspx?msg=2004501
A USB library for .Net - http://www.icsharpcode.net/OpenSource/SharpUSBLib/
A Java sample for a webcam app - http://www.mutong.com/fischer/java/usbcam/

Here is another great one for reading and writing to USB devices:
http://winusbnet.codeplex.com/

Related

Capture printer job data stream - Windows

I will be working with a mix of networked and local printers and need to capture the actual data sent for printing going to either local or networked printers.
I have looked over the print spooler api and some of it looks promising, but it seems like it would require acquiring jobID and finding the corresponding file (if you enable save to file for printing).
I have also seen an application called redmon that could work for my purposes but I was hoping to write a unique c# application to acquire the data and handle it.
My Goal: gather print data sent from an application I have no access to. I will then need to work with this data and possibly store it for later use. I obviously would prefer gathering this through print spooler api calls but it seems like this isn't functionality built into it. Any help would be appreciated.

Extract gps data storage

I am using dotSpatial labrary in c#, I only can read realtime data.
but my problem is this.. how could I extract gps data storaged in my usb-gps device (it is passive gps)?
device information
brand : landairsea
Model: Gps Tracking Key
webPage: http://www.landairsea.com/gps-tracker/gps-tracking-key
From looking at their user guide:
http://www.landairsea.com/downloads/past-track-10.pdf
You could use the past-track software to save the stored data as .las format.
I believe that DotSpatial has a LIDAR plug-in that can read .las files:
Dotspatial.Plugins.LiDAR
If you are asking how to write a C# replacement for the Past-Track program that connects directly to the USB however, I don't know exactly.
DotSpatial has a positioning library that is DotSpatial.Positioning that was originally ported from http://geoframework.codeplex.com/. It is possible that this utility will have the capability to connect to your device, but I think it would probably only support a limited subset of GPS devices, and I never used it myself at all.
Hopefully that information is a little helpful though and will point you in the right direction.
Edit:
I have downloaded the Past-Track 10 software that is designed to retrieve data from the unit. This in turn installed Antaris4 and u-blox5 USB drivers. I think this is half of what you will need to write a C# app that can talk to your GPS and do things in code. You can find the drivers on the web. I think I found it here:
http://www.driverguide.com/driver/detail.php?driverid=1869444
But make sure you find a version of the driver that matches your PC configuration (32/64 and correct operating system). Incidentally, that will probably mean you will need to make x86 and x64 builds for your C# app.
The next step is to find some documentation for it and then attempt to use the drivers from C#. So far I haven't found a good document showing how to work with the drivers, but I'm sure it exits. I will update with a link when I find it.

Capture all packets sent from and to application

I would like to capture all packets sent and received by application. Then edit some of them before they reach their destination (and delay them in some cases).
What is the best way to "inject" in that path of packets?
I want to do it with C++ and Windows api. (Maybe C# with pInvoke).
There'd no quick solution. You'll need a driver. Here's an example:
http://code.msdn.microsoft.com/windowshardware/NDISLWFSYS-Sample-NDIS-60-42b76875

how to implement video webcast on the website?

we have a video file which we have to "webcast" on the website (ASP.NET MVC 4 C#) to about 1000 users. I have absolutely no idea how to do this. I'm looking for answers to the following questions:
How webcasts are implemented in general? what are keywords I should be googling for?
How to synchronize video streams sent to different users?
How much computing power do I need for 1000 users? Need a rough answer of course. One server, or tens of servers.
any links, blog articles etc would be appreciated.
Thank you.
In general webcasts are implemented where there is a client software that sends tcp packets of stream data to server and server represents those packets as moving pictures.
In theory they already should be synchronized since you don't send the full video, you only send the current packets that are then buffered and represented as moving pictures. There will always be inconstancy in milliseconds because you cannot control every users ping to server.
It all depends on quality of your video as well as your webserver. No one will give you straight answer, you should always profile your applications on your own and see what bests fits your needs.
Since you are using C# MVC it is coupled with IIS, and IIS has something they call IIS Media Services that does exactly what you need. Definitely check it out.
Also you should check out c# live streadming in google, I found very interesting approach right here.
Well, as a streaming media person, here are my suggestions.
You could do a "live" webcast or an on-demand webcast depending on your choice. Live means, if you have a video file, you could broadcast it to multiple users at once and all will see it as if watching in a TV. They cannot pause your video. Normally, only live events are being broadcasted like this, unless you have a specific reason to broadcast an existing video file as a "fake" live broadcast.
You could use Windows Media Server (Add the media role in Windows Server 2003/2008/2012). Configuring and starting a windows media server needs intermediate level of familiarity with the streaming process, server, firewalls, exceptions. You have a lot of configurations which you can manage in this way, and generally suggested if you are very serious about your streaming. RTSP saves a lot of bandwidth for you too.
You could use Flash Media Server/Wowza media Server, Real Streaming Server also inplace of Windows media server.
For limited number of users, you can download the free Windows media Encoder, and select your file to be streamed, and click to stream easily. This is the easiest.
You could use managed streaming services from few thirdparties, like Livestream, Brightcove etc to stream video files.. Once you signup with them, the will give you an FTP/web space to upload your files, and they provide a link to the file (streaming media link). This link, you could embed in any popular player (like JWPlayer or any of that kind), and embed your player in your webpage for your users to start seeing the media. This is the most easy way to set it up. Maybe you can even get a 15 day trial services from brightcove or Mogolous.
Hope this answers your question.

How to read from a device's COM Port?

I´ve a device running Windows CE, which is capable to receive GPS datas. Now I wrote an application (C#, .Net Compact Framework 2.0 using VS2008) in order to receive this data and later on work with it.
The support contact of the device told me to use its COM port (number 5) to get the data.
As I´m not that experienced in working with C#, I have tried so hard to get the data (Longitude, Latitude) into my local variables … in vain.
My first idea was to add the library (*.dll) brought by the device’s SDK. There I found a structure which contains the variables dLongitude and dLatitude. I thought getting the values of this datas into my local variables would be the solution…result was: they only returned 0.0… … I can’t get rid of the feeling that I’m totally barking up the wrong tree…
(see my first question on this site)
You would help me so much, if you could give me a hint in which direction I have to go. I just don’t know how to read from device’s COM Ports or where to read about how to do so.
Thank you!!
GPS data through serial ports often follows the NMEA 0183 standard. It's pretty much just periodic human-readable numbers.

Categories