msp430 (telosb) adc driver for mq5 sensor in contiki - driver

I am trying to connect MQ5 sensor to a Telosb and read the values, and i am using contiki os.
My problem now is:
I know that i need an ADC driver in contiki os, but i do not know how to do it or from where to start ?
Can anyone guide me please?

The ADC driver for TelosB is already implemented in Contiki, you can find it in file sky-sensors.c and sky-sensors.h in contiki/platforms/sky.
See light-sensor.c and temperature-sensor.c for examples of sensor drivers that use this "sky_sensor" API. Basically you need to select which ADC input channel to use and what reference voltage to use, the rest is trivial: call sky_sensors_configure function and read from the right memory location mapped to an ADC input port. For example, by reading ADC12MEM4 you can access the ADC channel 4.

Related

Requirements for initiating a print on a 3D printer via USB

I thought it would be fun to implement a rudimentary version of Octoprint that can receive a gcode file and initiate a print on my Prusa i3.
What are the requirements for initiating a print on a 3D printer via USB?
You can use the pySerial library in Python to send raw G-Code to the /dev/ttyWhereverYourPrinterIs serial device. Most printers specify their baud rate in their UI, or user's manual. My printer says its USB baud rate is 115200.
Quoting Gina Häußge:
If you are only targeting a very specific printer with a very specific firmware variant: serial connection and then read up on https://reprap.org/wiki/G-code. It becomes a horrible nightmare to implement and maintain though when you take the thousands of firmware variants out there into account, so beware.

Wireshark does not capture dpdk interface packets

I am trying to capture the data packets from dpdk interface.
Using pdump+testpmd, able to capture the data packets.
However, if Wireshark is used with testpmd, the above fails.
Any suggestions highly appreciated. Thanks
Working on Ubuntu v 18+, DPDK v 19+ Wireshark v 3+
The solution is to use the pdump application. As others mentioned, once your DPDK application takes ownership of the network card, the kernel will not see the packets, and tcpdump hooks will not be triggered.
The documentation explains how to i) compile dpdk with support for pdump and pcap ii) enable your primary process - your application - to give packet information to a secondary process - the pdump sample application.
You can then use the generated pcap with wireshark.
As soon as you bind the physical interface from kernel to a DPDK driver (igb_uio, uio_pci_generic, vfio-pci) it becomes removed from kernel netdev for both Physical Function and Virtual Function. These NIC ports are accessible via UIO driver, and application like DPDK which has the PMD can probe and init the devices (with some exceptions).
If you want to use the port with Wireshark, unfortunately you have to bind it back to the kernel. You can also just capture packets to a .pcap file using DPDK and analyse it with Wireshark offline - if that fits your needs.
[EDIT-1] There are 2 ways to capture packets on UIO DPDK bind
make use of rte_pdump_init API in the primary (desired) DPDK application and use DPDK example dpdk-pdump to capture packets for RX or TX for desired queues.
Unbind the device from UIO and bind it back to kernel driver for netdev interface. start the DPDK rte_eal_init with special argument --vdev=net_pcap0,iface=[kernel nic interface instance]
Note: In option 2, one can run Wireshark and capture the packets too. But will lose out on performance and DPDK specific functionality.

Sending JPEG image into AXI4 stream and reading it back?

I'm doing an image processing project on Zedboard Zynq evaluation board, using the FPGA built on it. I have written the image processing block using HLS and created the IP with both input and output as AXI4 streams with width 8.
How do I read a JPEG image on my PC and send it as an AXI4 stream to this IP block, and output it back to show it on my PC screen ?
Are there any existing IPs which accomplish this ?
P.S. The FPGA board is connected to my PC via JTAG cable, in case it's relevant.
The exchange of image data between the programmable logic (PL) and the processing system (PS) of the Zynq, can be established using direct memory access (DMA)/video direct memory access(VDMA).
This functionally is provided by Xilinx as an IP core. This IP core implements the receiving and transmitting of image data on PL side as an AXI stream.
On PS side the DMA can be made accessible by using the linux UIO. For this purpose you have to modify the device tree node of the DMA IP core in the device tree of the ARM core. If this is done, the DMA is available under /dev/ in the linux system.
Now it can be mapped to the user space using mmap(). By configuring the DMA, a memory area in the RAM of the PS has to be assigned to it. This memory area is used to implement a so called stream buffer. The DMA core uses this stream buffer to read or write image data. At the same time a linux application can access this memory area. This allows exchange of data between PS and PL.
A detailed description of the individual registers and the configuration procedure can be found in Xilinx's AXI DMA/VDMA product guide.
As far as the image data is available in the user space, the Ethernet connection could be used to send the image to the host PC. The JTAG connection is not the proper way to exchange image data between a host PC and the Zed board.

How to use librte_pmd_pcap of dpdk in our own dpdk app for packet capturing?

I am new to DPDK, I'm trying to write my own app, which would capture packets at wire rate. Can I use the default kernel space libpcap long with dpdk ring and lcore. Or can I use the librte_pmd_pcap which is part of dpdk package.
Librte_pmd_pcap internally uses kernel space libpcap.
And I don't know how to use librte_pmd_pcap in my own dpdk app.
Can someone help me in using the librte_pmd_pcap in our own dpdk app to capture tcp packets.
*I have tested the testpmd app that comes with the dpdk package, testpmd is working fine. I need your help in writing my own dpdk app. Thanks in advance.
I was able to include the rte_eth_pcap.c to the application code and access the api. And this allowed me to use the -vdev EAL option to my app.
If by "the librte_pmd_pcap" you're referring to this source file, it uses libpcap, which is a user-mode library; it's not part of the kernel. It uses kernel-mode mechanisms on the operating systems (plural) that it supports; it uses BPF on *BSD, OS X, and Solaris 11; it uses PF_PACKET sockets on Linux (unless you're on an ancient Linux, in which case it uses SOCK_PACKET sockets); etc..
You can use libpcap directly, which will use the same kernel mechanism that any other code using libpcap does, including the code I linked to.

Parsing packets captured using wireshark for management frames identification using libpcap or similar library

I want to parse packets captured by wireshark offline using libpcap. I am capturing packets from a wireless network in monitor mode. I have read that "libpcap" can be used to capture and parse packets captured in the ethernet. Can it be used for wireless networks too? If yes, can anyone suggest me some tutorial? and if No, which library is suitable for it and how to use it?
libpcap, and its Windows port, WinPcap can be used to capture network traffic (in fact, they're what Wireshark uses to capture network traffic), as well as to read a capture file in pcap format (the default format for Wireshark's existing releases) and, in libpcap 1.1 and later, to read some capture files in pcap-ng format (the default format for the current development version of Wireshark; it should write out files that libpcap 1.1 and later can read).
They can handle a number of network types, including Ethernet and Wi-Fi.
They do not, however, support parsing any packet types; that's the job of the code that uses them, whether it's tcpdump/WinDump, Wireshark, or some other application. There's a library called WiFiPcap that is:
A C++ wrapper around libpcap that parses 802.11 frames, and the most common layer 3 (IPv4, IPv6, ARP) and layer 4 protocols (TCP, UDP, ICMP) contained within them. Also works without link-layer headers. Works in Linux and Windows.
(copied from its web page, but edited to fix the protocol layer numbers to match the OSI model).
I have not looked at it, but it might do what you want.
There might also be other libraries that could be used to parse the packets.

Resources