<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to read nrf sniffer 4.1.0 serial data in C?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85033/how-to-read-nrf-sniffer-4-1-0-serial-data-in-c</link><description>I&amp;#39;m trying to work with Kismet&amp;#39;s nrf51822 plugin that would allow kismet to read the nRF BLE sniffer 4.1.0 the same way Wireshark does. Alas, theirs is C based and I don&amp;#39;t seem to get the right data off my nRF51 DK reading its serial port in C the way</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 Feb 2022 12:42:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85033/how-to-read-nrf-sniffer-4-1-0-serial-data-in-c" /><item><title>RE: How to read nrf sniffer 4.1.0 serial data in C?</title><link>https://devzone.nordicsemi.com/thread/355024?ContentTypeID=1</link><pubDate>Fri, 25 Feb 2022 12:42:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1cb7299-6029-4726-b284-bd1f5aa5f962</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;True, we use python and not C. Can&amp;#39;t really help you with making it work with C.&lt;/p&gt;
&lt;p&gt;However, there is an open-source application in C already that uses the sniffer UART protocol.&lt;/p&gt;
&lt;p&gt;You might have a look here: &lt;a title="https://github.com/homewsn/bsniffhub" href="https://github.com/homewsn/bsniffhub" rel="noopener noreferrer" target="_blank"&gt;https://github.com/homewsn/bsniffhub&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;-Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read nrf sniffer 4.1.0 serial data in C?</title><link>https://devzone.nordicsemi.com/thread/354877?ContentTypeID=1</link><pubDate>Thu, 24 Feb 2022 17:30:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a01dba7-c349-4533-86dd-f1d1e15b21ae</guid><dc:creator>Matthew C Clark</dc:creator><description>&lt;p&gt;Yes, I found that last night.&amp;nbsp; Right now my main issue is&amp;nbsp;that when I try to read the fd via:&lt;/p&gt;
&lt;p&gt;res = read(localnrf-&amp;gt;fd, buf, 255);&lt;/p&gt;
&lt;p&gt;I get the buffers of random lengths listed above.&amp;nbsp; I&amp;#39;ve not been able to find a simple C example that properly manages it.&amp;nbsp; Wireshark uses your python interface.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read nrf sniffer 4.1.0 serial data in C?</title><link>https://devzone.nordicsemi.com/thread/354737?ContentTypeID=1</link><pubDate>Thu, 24 Feb 2022 08:54:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00200884-02d3-4ed5-a203-2be2a085ce5a</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the 4.1.0 release in the doc folder there is a sniffer_uart_protocol.txt document that you can use.&lt;/p&gt;
&lt;div&gt;-Amanda&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read nrf sniffer 4.1.0 serial data in C?</title><link>https://devzone.nordicsemi.com/thread/354692?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 21:12:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:903fa779-3304-4ade-9979-19fff5bd41fc</guid><dc:creator>Matthew C Clark</dc:creator><description>&lt;p&gt;Following up a bit, I managed to play with settings to get data across the line.&amp;nbsp; Though the serial read is still a bit wonky as I get varying buffer sizes (see below), it appears at least for the nRF51, you&amp;#39;re using SLIP for packet coding?&amp;nbsp; The code looks for 0xAB (SLIP_START) and 0xBC (SLIP_END).&amp;nbsp; Is this correct?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;buf_rx_len = 4 0xBC 0xAB 0x2B 0x0&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0x3 0xB6&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 1 0x23&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 3 0x2 0xA 0x1&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0x26 0x54&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 3 0x0 0x0 0x39&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0xCB 0x5&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 1 0xB&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 4 0xD6 0xBE 0x89 0x8E&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 1 0x0&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 4 0x17 0x0 0xCA 0x91&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0x2F 0x85&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 1 0x4A&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 3 0x6C 0x2 0x1&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 3 0x1A 0x2 0xA&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0xC 0xA&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 1 0xFF&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 3 0x4C 0x0 0x10&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0x5 0xA&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0x14 0x33&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 2 0x3C 0x76&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 3 0xF5 0x2B 0x92&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 1 0xBC&lt;/code&gt;&lt;br /&gt;&lt;code&gt;buf_rx_len = 3 0xAB 0x2B 0x0&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read nrf sniffer 4.1.0 serial data in C?</title><link>https://devzone.nordicsemi.com/thread/354629?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 14:41:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd966056-a340-48ca-9168-7315dfd03843</guid><dc:creator>Matthew C Clark</dc:creator><description>&lt;p&gt;Thanks, Amanda, I&amp;#39;ll give that a try. If it helps, this is the code in kismet that attempts to open /dev/ttyACM0 where my nRF attaches.&amp;nbsp; If there are any settings you know that should be on/off, please let me know?&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* open for r/w but no tty */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; localnrf-&amp;gt;fd = open(device, O_RDWR | O_NOCTTY);&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;if (localnrf-&amp;gt;fd &amp;lt; 0) {&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; snprintf(msg, STATUS_MAX, &amp;quot;%s failed to open serial device - %s&amp;quot;,&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; localnrf-&amp;gt;name, strerror(errno));&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; return -1;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;nbsp;/* save current serial port settings */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; tcgetattr(localnrf-&amp;gt;fd,&amp;amp;localnrf-&amp;gt;oldtio);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* clear struct for new port settings */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; bzero(&amp;amp;localnrf-&amp;gt;newtio,sizeof(localnrf-&amp;gt;newtio));&amp;nbsp;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* set the baud rate and flags */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; localnrf-&amp;gt;newtio.c_cflag = localnrf-&amp;gt;baudrate | CRTSCTS | CS8 | CLOCAL | CREAD;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* ignore parity errors */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; localnrf-&amp;gt;newtio.c_iflag = IGNPAR;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* raw output */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; localnrf-&amp;gt;newtio.c_oflag = 0;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* newtio.c_lflag = ICANON; */&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* flush and set up */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; tcflush(localnrf-&amp;gt;fd, TCIFLUSH);&lt;/code&gt;&lt;br /&gt;&lt;code&gt; tcsetattr(localnrf-&amp;gt;fd, TCSANOW, &amp;amp;localnrf-&amp;gt;newtio);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;return 1;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read nrf sniffer 4.1.0 serial data in C?</title><link>https://devzone.nordicsemi.com/thread/354563?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 12:35:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89ec5df4-9876-4068-acf4-cdb90a3a0440</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The speed should be 1M (1000000).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Flow control does not really matter since it is a virtual COM port. However, HW FC is on between the VCOM and the nRF COM. The argument provided to stty will not have any effect.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>