C program to read datas from an antenna connected with USB - c

i'm trying to write a C program to read datas from an antenna connected with USB. I never did something like this and i'm totally confused. I'm using Windows SO, but i don't know how to access to the device and how to read datas. Can you help me? There are specific functions to do that?

Related

Reading sound card data on RaspberryPi using C

I want to read the data generated by USB sound card connected to my RaspberryPi using a C code. The samples should be stored in an array or are written to a csv file.
I am using ALSA library through a function "snd_pcm_readi". Can someone explain how to access the data read by "snd_pcm_readi"?
Or is there a better alternative?
Look at the libusb library, https://libusb.info/
This library gives you simple C functions to find and open the device, and then send and receive data. You may want to do some reading about USB devices.
You may also want to look at udev - you can write a udev rule to symbolically link the desired device to a known filename.
You may need to know the vendor_id and product_id. At the command line, enter lsusb to see the usb devices.

How to send data from Arduino Uno to PC using the USB port

I'm building an NFC project in which I have an Arduino Uno with a PN532 NFC shield that reads stored messages from tags. What I'm trying to achieve is to store/write the information to a .csv file, but I need to send the data over the USB cable through which the Uno is connected to on my PC.
Is there any way to write the data to .csv file onto the Arduino, then send the .csv file to the PC over the USB cable to a given directory, or write a program that reads the data being sent from the Uno through the USB cable, and then write the data on the PC to a .csv file? I'm aware I could get a breadboard with an SD card reader, and write the data to an SD card but I'm trying to avoid this solution if possible. Is there any way to send files or data over USB from Arduino to PC?
I would definitely have the Arduino send the values over the USB interface and have the host run a Python program that uses the CSV library to write a .csv file.
You could simply "print" the values from the Arduino to the USB interface and read them on the host using /dev/ttyUSBx. But at some point you might want to send control commands to the Arduino. And you might want to do some logging, catch errors, etc. If so, I suggest that you look at a full-fledged communication protocol. I realize you're not controlling a robot, but rosserial from Robot Operating System (ROS) would make this easy. It might feel like overkill but I think you'll appreciate the features once you start using it.
Do you need an example?

Get PID/VID nunbers from any usb device

I am learning linux-kernel and driver, and just a newbie. I want to write a "driver" which can get PID/VID of any usb device, then print those numbers into kernel log.
As far as i know, USB HCI detects PID/VID from attached USB device,and pass to usbcore, even if it does not have right driver. So there must be some APIs to get it, but I dont know.
Any one can help me?
Please use 'lsusb' to get those details

Hooking network functions using a driver, a high-level overview?

I have just managed to write my first windows driver (havent registered it yet- but i managed to get the things created!).
I wondered if someone can give me a high overview of how I could achieve the following:
I would like to write a driver which will implement some behaviour when a network packet is received by the computer, before windows does what it does with the packet, i'd like to take this data and output it to the console of a C or C++ program.
Lets assume I have a C/C++ program written, which has a console. How does the C/C++ program interact with the driver I wrote which is hooking the network activity? Is it simply some C code which calls my drivers, the function returns the data as an object and then I can use that object to display in the console?
Thank you in advance for any possible replies
You don't need a driver for this task. Use packet sniffer library like PCap (actually you'll need WinPCap). It's really simple to capture packets and print them to console.
Alternative way is raw socket. But desktop Windows (as opposite to Windows Server) limits raw socket functionality.
If you really want a driver, or have a requirement to manipulate or filter packets before they hit the windows network stack you need to look into filter drivers.
This filter driver can then expose a device file on which your user space application can then read/write. The windows DDK contains examples.

Simulate serial port

I am writing a C program in Linux which will read/write to/from a serial port. I know the data that needs to be read and written on the port but I don't have a serial port to currently test this with.
Is there any way to simulate a serial port? Would reading/writing to a file be sufficient? I can have one process write to the file while another process reads that data and writes back other data to the file. Or are there others tools that can be used to simulate a port?
Thanks
Serial ports on Linux are terminal devices. A close simulation is to create a pseudo-terminal pair; the program that normally talks to the serial port is instead told to open the slave side of the pseudo-terminal, and the simulator writes and reads from the master side.
The pty(7) man page has more information.
Despite being an old topic, and my answer is not exactly something the OP was looking for, I decided to share my experience, as someone else might come across it like I did. Instead of straightforward simulation, I used the software called Serial to Ethernet Connector to gain access to the specific device I needed to test the app with. Worked nicely for me.
A character device, even something as simple as normal stdin and stdout should work if you don't care about attributes specific to port devices.

Resources