Giter Club home page Giter Club logo

pyspinel's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyspinel's Issues

Unhandled None from stream_rx

Also in some testruns we see the following exception:

Exception in thread Thread-11:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 911, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 859, in run
self._target(*self._args, **self._kwargs)
File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 972, in stream_rx
self.rx_pkt = self.hdlc.collect()
File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/hdlc.py", line 113, in collect
packet = pack("%dB" % len(packet), *packet)
TypeError: object of type 'NoneType' has no len()

Unfortunately, this error above is non deterministic, most likely it happens is serial connection doesn't reply properly. Nevertheless, pyspinel should handle such case gracefully.

Error when creating sniffer for OpenThread

Hello,

I'm trying to build a sniffer for an OpenThread network using this tutorial.
I built the openthread/ot-nrf528xx binaries using the USB_trans-Flag, flashed the ot-rcp.hex-File onto a Adafruit Feather nrf52840 and disabled the MSD. After that I created a small OpenThread network with only one router and one child (Also on Adafruit Feather nrf52840 devices).

My problem now is when I try to run the sniffer.py with following command: sudo python3 sniffer.py -c 15 -u /dev/ttyACM0 --crc --no-reset --rssi | wireshark -k -i - (with -c 15 being the channel I use in the OpenThread network and -u /dev/ttyACM0 being the USB-Port where the sniffer is connected.), I get the following log output and error message:

Initializing sniffer...

CB_Unknown (3): 
 ** (wireshark:11740) 12:27:54.470908 [Capture MESSAGE] -- Capture Start ...

CB_Unknown (3): 
ERROR: failed to initialize sniffer
 ** (wireshark:11740) 12:27:57.356867 [Capture MESSAGE] -- Error message from child: "Data written to the pipe is neither in a supported pcap format nor in pcapng format.", "Please report this to the developers of the program writing to the pipe."

Wireshark is opened, but displays the same error message.

Can anybody tell me what I'm doing wrong? Did I miss a step or do I maybe have to set something in wireshark?

PS: I'm using Ubuntu Linux.

Thanks for any help,

Emily

Allowlist not being unpacked

The MAC_ALLOWLIST type is not being unpacked. This means consumers are unable to view the allowlist. Any attempt to read the values always returns None (ie, value = self.prop_get_value(SPINEL.PROP_MAC_ALLOWLIST) will always yield a value of None for the variable value)

Information to reproduce the behavior, including:

  1. Git commit id: 454dd9c
  2. IEEE 802.15.4 hardware platform: SiLabs EFR32MG13 (though this isn't related to hardware)
  3. Build steps: Build an NCP with MAC_FILTER=1
  4. Network topology: No additional nodes needed

Expected behavior
The MAC_ALLOWLIST is processed and returned when calling self.prop_get_value(SPINEL.PROP_MAC_ALLOWLIST).

Openthread repo no longer includes pyspinel in tools directory

The readme mentions installing pyspinel from within the root openthread repository, in the tools directory. The openthread repository does not contain pyspinel within the tools directory.

Attempting to install from this directory and run spinel-cli.py results in:

$ sudo python setup.py install
$ ./spinel-cli.py 
Opening pipe to ../../examples/apps/ncp/ot-ncp-ftd 1
/bin/sh: 1: ../../examples/apps/ncp/ot-ncp-ftd: not found
Traceback (most recent call last):
  File "./spinel-cli.py", line 2287, in <module>
    main()
  File "./spinel-cli.py", line 2276, in main
    shell = SpinelCliCmd(stream, nodeid=options.nodeid)
  File "./spinel-cli.py", line 190, in __init__
    self.prop_set_value(SPINEL.PROP_IPv6_ICMP_PING_OFFLOAD, 1)
  File "./spinel-cli.py", line 330, in prop_set_value
    return self.wpan_api.prop_set_value(prop_id, value, py_format)
  File "/home/nealjack/git/pyspinel/spinel/codec.py", line 1106, in prop_set_value
    value, py_format, tid)
  File "/home/nealjack/git/pyspinel/spinel/codec.py", line 1081, in __prop_change_value
    self.transact(cmd, pay, tid)
  File "/home/nealjack/git/pyspinel/spinel/codec.py", line 908, in transact
    self.stream_tx(pkt)
  File "/home/nealjack/git/pyspinel/spinel/codec.py", line 946, in stream_tx
    self.stream.write(pkt)
  File "/home/nealjack/git/pyspinel/spinel/stream.py", line 112, in write
    self.pipe.stdin.write(data)
IOError: [Errno 32] Broken pipe

spinel-cli.py failed to decode NCP logs

Describe the bug
spinel-cli.py failed to print NCP logs, when connecting to a nrf52840

To Reproduce

I installed pyspinel via pip3 install pyspinel.
Platform repo: https://github.com/openthread/ot-nrf528xx
Commit id: 2b19d73a9bf4526de4745190dc73728b12edd923

In src/nrf52840/openthread-core-nrf52840-config.h, I defined OPENTHREAD_CONFIG_LOG_OUTPUT as OPENTHREAD_CONFIG_LOG_OUTPUT_APP.

Then I built and flashed the board:

 8987  [2021-04-28 19:08:41 +0800] ./script/build nrf52840 UART_trans -DOT_FULL_LOGS=ON -DOT_JOINER=ON 
 8988  [2021-04-28 19:09:01 +0800] cd build/bin/
 8989  [2021-04-28 19:09:04 +0800] arm-none-eabi-objcopy -O ihex ot-ncp-ftd ot-ncp-ftd.hex 
 8990  [2021-04-28 19:09:06 +0800] nrfjprog -f nrf52  --chiperase --program  ot-ncp-ftd.hex 

Finally I connected to the board using spinel-cli. I ran a few usual thread CLI commands:

ifconfig up
ifconfig
thread start
state

However the spinel CLI showed errors when it was expected to print logs:

CB_Unknown (6): 
Traceback (most recent call last):
  File "**************************************/pyspinel/spinel/codec.py", line 1110, in parse_rx
    handler(self, payload, tid)
  File "************************************/pyspinel/spinel/codec.py", line 808, in PROP_VALUE_IS
    self.handle_prop(wpan_api, "IS", payload, tid)
  File "**********************************/pyspinel/spinel/codec.py", line 772, in handle_prop
    prop_value = handler(wpan_api, payload[prop_len:])
  File "********************************/pyspinel/spinel/codec.py", line 728, in STREAM_LOG
    return self.parse_fields(payload, "UD")
  File "*****************************/pyspinel/spinel/codec.py", line 299, in parse_fields
    result.append(cls.parse_field(payload, format))
  File "*********************************/pyspinel/spinel/codec.py", line 197, in parse_field
    return map_decode[spinel_format[0]](payload)
  File "*********************************/pyspinel/spinel/codec.py", line 122, in parse_U
    payload = payload.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 60: invalid start byte

FWIW, if I add a line print(payload) at line 122 in pyspinel/spinel/codec.py, it will be able to print lines like:
b'[DEBG]-MAC-----: Frame rx failed, error:DestinationAddressFiltered\x00\x07\x07\xa5\x9b\x10\x00\x00\x00\x00\x00'.
This proves that spinel-cli.py failed to decode logs.

Fix python3 support

Seems that the pyspinel package has some python3 compatibility:
codec.py:

is_py2 = sys.version[0] == '2'
if is_py2:
    import Queue as Queue
else:
    import queue as Queue

Unfortunately, it doesn't work:

Opening serial to /dev/ttyACM0 @ 115200
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 859, in run
    self._target(*self._args, **self._kwargs)
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 947, in stream_rx
    self.rx_pkt = self.hdlc.collect()
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/hdlc.py", line 79, in collect
    byte = self.stream.read()
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/stream.py", line 71, in read
    return map(ord, pkt)[0]
TypeError: 'map' object is not subscriptable

There are several other places in which the fixes would be needed: python2 serial uses str, while py3 returns bytes. Refactoring this package should be quite simple for someone familiar with the protocol.

Tag v1.0.0a2 release

I see there's been a few commits since the last version was tagged. @jwhui perhaps we could tag v1.0.0a2 and I'll release it on pypi?

UnboundLocalError: local variable 'metadata' referenced before assignment

Sniffer ended with next error:

  File "/home/jag1/repos/kng-verification/.venv/py3/bin/sniffer.py", line 242, in <module>
    main()
  File "/home/jag1/repos/kng-verification/.venv/py3/bin/sniffer.py", line 226, in main
    pkt = pcap.encode_frame(pkt, int(timestamp_sec), timestamp_usec, options.rssi, options.crc, metadata)
UnboundLocalError: local variable 'metadata' referenced before assignment

It occurs in case of: Some old version NCP doesn't contain timestamp information in metadata

spinel-cli, scan bug

Hi, I am trying to develop a Thread application and need to scan for all Thread networks before joining. The spinel-cli provides the scan command which would be useful. But somehow it never finds any network. Output is:

Done
Done
Done
Error

Using an:
ID 1915:cafe Nordic Semiconductor ASA nRF52840 MDK USB Dongle

The Error at the end appears after each "scan".

Best regards,

Mart

struct.error after PR#46

The following issue happens on current master. The 86ea36f4616307c2d51fb7ce1d5a3c0d788b8fb8 works fine.

Currently there are lots of "unpack requires a bytes object of length 2" struct.error exceptions happening in codec.THREAD_CHILD_TABLE:

      CB_Unknown (6):
Traceback (most recent call last):
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 946, in parse_rx
    handler(self, payload, tid)
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 753, in PROP_VALUE_IS
    self.handle_prop(wpan_api, "IS", payload, tid)
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 717, in handle_prop
    prop_value = handler(wpan_api, payload[prop_len:])
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 491, in THREAD_CHILD_TABLE
    def THREAD_CHILD_TABLE(self, _, payload): return self.parse_fields(payload, "A(ESLLCCcCc)")
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 268, in parse_fields
    array.append(cls.parse_fields(payload, array_format))
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 289, in parse_fields
    result.append(cls.parse_field(payload, format))
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 191, in parse_field
    return map_decode[spinel_format[0]](payload)
  File "/wrk/kng-verification/.venv/py3/lib/python3.4/site-packages/spinel/codec.py", line 99, in parse_S
    def parse_S(cls, payload): return unpack("<H", payload[:2])[0]
struct.error: unpack requires a bytes object of length 2

I dumped the problematic payload and here is its hexified version:

ERROR:codec:497: ['17', '00', '3E', '4C', 'DC', '6D', '08', '78', 'AA', 'C1', '01', '3C', '1E', '00', '00', '00', '0B', '00', '00', '00', 'C2', '03', 'E4', '0F', 'E3', '17', '00', '56', 'E5', 'E0', '8E', '42', '35', '34', '60', '02', '3C', '1E', '00', '00', '00', '09', '00', '00', '00', 'C2', '03', 'EE', '0D', 'ED']

It seems that depending on situation openthread uses A(ESLLCCcCc) or A(t(ESLLCCcCc)) as a child table format.

Simple workaround for the issue:

diff --git a/spinel/codec.py b/spinel/codec.py
index b982d06..e28f84a 100644
--- a/spinel/codec.py
+++ b/spinel/codec.py
@@ -488,7 +488,11 @@ class SpinelPropertyHandler(SpinelCodec):
 
     def THREAD_PARENT(self, _wpan_api, payload): return self.parse_fields(payload, "ES")
 
-    def THREAD_CHILD_TABLE(self, _, payload): return self.parse_fields(payload, "A(ESLLCCcCc)")
+    def THREAD_CHILD_TABLE(self, _, payload):
+        try:
+            return self.parse_fields(payload, "A(ESLLCCcCc)")
+        except structerror:
+            return self.parse_fields(payload, "A(t(ESLLCCcCc))")
 
     def THREAD_LEADER_RID(self, _, payload): return self.parse_C(payload)

[style] add style check to travis-ci

Is your feature request related to a problem? Please describe.
I think we should include python code style check and pretty tool for this project.

nrf-util error while changing NCP network parameters

So we are using NCPTransport from nrf-util (nordicsemi/thread/tncp.py) to have CoAP connectivity over Thread NCP from Raspberry Pi to other Thread devices. We have a use case where we need to reconfigure NCP network parameters in order to reach device in another network. The problem is that we get errors while re-opening NCPTransport with new (or even the same) parameters.

NCP connected to RPi over Serial /dev/ttyS0.
NCP based on nRF5 SDK for Thread and Zigbee v2.0.0.

Python packages:
pyserial (3.4)
pyspinel (1.0.0a3)

Our test code in Python:

import logging

logging.basicConfig(
    format='%(asctime)s %(name)-6s %(message)s',
    datefmt='%H:%M:%S')

import time

class Thread:
    def __init__(self):
        self.log = logging.getLogger('Thread')
        self.log.setLevel(logging.INFO)

    def run(self):
        from nordicsemi.thread.tncp import NCPTransport

        self.log.info("Starting...")

        port = '/dev/ttyS0'
        stream_descriptor = 'u:' + port

        config = {NCPTransport.CFG_KEY_CHANNEL: 19,
                  NCPTransport.CFG_KEY_PANID: 0xbfb4,
                  NCPTransport.CFG_KEY_RESET: True}

        transport = NCPTransport(5683, stream_descriptor)
        transport.open()
        time.sleep(2)
        transport.close()
        time.sleep(2)


Thread().run()
Thread().run()

and logs:

17:14:39 Thread Starting...
17:14:40 nordicsemi.thread.tncp Attaching to the network
17:14:45 nordicsemi.thread.tncp Done
17:14:45 nordicsemi.thread.tncp NCP Thread IPv6 addresses:
17:14:45 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:fc10
17:14:45 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:fc00
17:14:45 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:0
17:14:45 nordicsemi.thread.tncp fe80::1837:7abe:9451:7b67
17:14:45 nordicsemi.thread.tncp fd4a:b255:f83d:0:2706:3899:e257:fb06
17:14:50 Thread Starting...
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/spinel/codec.py", line 965, in stream_rx
    self.rx_pkt = self.hdlc.collect()
  File "/usr/local/lib/python2.7/dist-packages/spinel/hdlc.py", line 80, in collect
    byte = self.stream.read()
  File "/usr/local/lib/python2.7/dist-packages/spinel/stream.py", line 69, in read
    pkt = self.serial.read(size)
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 501, in read
    'device reports readiness to read but returned no data '
SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

Traceback (most recent call last):
  File "ncp_forming.py", line 34, in <module>
    Thread().run()
  File "ncp_forming.py", line 27, in run
    transport.open()
  File "/tmp/nfs/factory_validation/app/src/nordicsemi/thread/tncp.py", line 224, in open
    raise Exception('Failed to reset NCP. Please flash connectivity firmware.')
Exception: Failed to reset NCP. Please flash connectivity firmware.

We tried to fix it by adding close implementation to class StreamSerial() in spinel/stream.py:

    def close(self):
        print("Closing serial")
        self.serial.close()

and now it works better, network is formed again, but still we get exception like below:

17:16:56 Thread Starting...
17:16:56 nordicsemi.thread.tncp Attaching to the network
17:17:01 nordicsemi.thread.tncp Done
17:17:01 nordicsemi.thread.tncp NCP Thread IPv6 addresses:
17:17:01 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:fc10
17:17:01 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:fc00
17:17:01 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:0
17:17:01 nordicsemi.thread.tncp fe80::1837:7abe:9451:7b67
17:17:01 nordicsemi.thread.tncp fd4a:b255:f83d:0:2706:3899:e257:fb06
Closing serial
17:17:05 Thread Starting...
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/spinel/codec.py", line 965, in stream_rx
    self.rx_pkt = self.hdlc.collect()
  File "/usr/local/lib/python2.7/dist-packages/spinel/hdlc.py", line 80, in collect
    byte = self.stream.read()
  File "/usr/local/lib/python2.7/dist-packages/spinel/stream.py", line 69, in read
    pkt = self.serial.read(size)
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 493, in read
    buf = os.read(self.fd, size - len(read))
TypeError: an integer is required

17:17:06 nordicsemi.thread.tncp Attaching to the network
17:17:11 nordicsemi.thread.tncp Done
17:17:11 nordicsemi.thread.tncp NCP Thread IPv6 addresses:
17:17:11 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:fc10
17:17:11 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:fc00
17:17:11 nordicsemi.thread.tncp fd4a:b255:f83d::ff:fe00:0
17:17:11 nordicsemi.thread.tncp fe80::1837:7abe:9451:7b67
17:17:11 nordicsemi.thread.tncp fd4a:b255:f83d:0:2706:3899:e257:fb06
Closing serial

A relevant ticket has already been created in Nordic DevZone.
A bug has been confirmed, it's located in pyspinel, and is related to improper handling of serial transport closure.
Please see details in the ticket: https://devzone.nordicsemi.com/f/nordic-q-a/45634/nrf-util-error-while-changing-ncp-network-parameters

Sniffer not working for KW41Z NCP node

Use the KW41Z NCP node, build like this:

make -f examples/Makefile-kw41z LINK_RAW=1 COAP=1 JOINER=1

Program ot-ncp-ftd binary
Download pyspinel v1.0.0a3
Open the sniffer with wireshark like described here:

11:45:20 $ sudo  python2 sniffer.py -c 18 -n 1 --crc --no-reset -u /dev/ttyACM0 | wireshark -k -i -
Initializing sniffer...
SUCCESS: sniffer initialized
Sniffing...
11:50:17.848          Warn Error "Less data was read than was expected" while reading "/tmp/wireshark_-_20181026115017_r3C2lf.pcapng"

In wireshark, when pressing start, I get the error "Unrecognized libpcap format or not libpcap data."

Running thread-cert tests on a SOC

I'm trying to run thread-cert tests on SOCs, which are connected over UARTs to a PC. So I was doing something like that:
NODE_TYPE=soc top_builddir=../../.. python Cert_6_3_01_OrphanReattach.py

This threw the error:

ERROR: test (__main__.Cert_5_1_02_ChildAddressTimeout)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Cert_5_1_02_ChildAddressTimeout.py", line 50, in setUp
    self.nodes[i] = node.Node(i, (i in MTDS), simulator=self.simulator)
  File "/home/[email protected]/projects/pan/pan/openthread/tests/scripts/thread-cert/node.py", line 55, in __init__
    self.__init_soc(nodeid)
  File "/home/[email protected]/projects/pan/pan/openthread/tests/scripts/thread-cert/node.py", line 149, in __init_soc
    import fdpexpect
ImportError: No module named fdpexpect

I fixed this by:

diff --git a/openthread/tests/scripts/thread-cert/node.py b/openthread/tests/scripts/thread-cert/node.py
index c484d9dd..0adff6e3 100755
--- a/openthread/tests/scripts/thread-cert/node.py
+++ b/openthread/tests/scripts/thread-cert/node.py
@@ -146,9 +146,9 @@ class Node:
 
     def __init_soc(self, nodeid):
         """ Initialize a System-on-a-chip node connected via UART. """
-        import fdpexpect
+        import pexpect.fdpexpect as fdpexpect
 
-        serialPort = '/dev/ttyUSB%d' % ((nodeid - 1) * 2)
+        serialPort = '/dev/ttyUSB%d' % (nodeid - 1)
         self.pexpect = fdpexpect.fdspawn(
             os.open(serialPort, os.O_RDWR | os.O_NONBLOCK | os.O_NOCTTY)
         )

I did the second modification in the diff above, because I've seen that (nodeid-1) is multiplied by two, which I don't understand, because the name of the interfaces to be used, are derived from that. My devices are attached to /dev/ttyUSB[0-2], while the original code tries to use /dev/ttyUSB0, /dev/ttyUSB2 and /dev/ttyUSB4. With my modifications everything works. Can somebody elaborate on that? Thanks.

sniffer does not work after "SUCCESS: sniffer initialized"

Describe the bug

It caught few packets in beginning (sometimes from my network on channel 11), after it did not show anything else. SiLabs sniffer shows activity on same channel.

To Reproduce
Information to reproduce the behavior, including:

  1. 06bff96310b75947e7897a4b3b6fc1ddae4ae21d
  2. efr32mg13p732f512gm48
  3. make -f examples/Makefile-efr32 SERVICE=1 BORDER_ROUTER=1 COAP=1 UDP_PROXY=1 LINK_RAW=1 BOARD=BRD4168A
  4. 1x OTBR, 1xFTD, 1xSniffer

Expected behavior
Wireshark must catch periodical MLE or whatever messages

Console/log output
Initializing sniffer...
SUCCESS: sniffer initialized
Sniffing...

Additional context
Ubuntu 18.04
ran "sudo python2 ./sniffer.py -c 12 -n 2 --rssi --no-reset -u /dev/ttyUSB1 -b 250000 | wireshark -k -i -"

Move parsers out of spinel-cli

There's a lot of useful code in spinel-cli.py (e.g. child table parsers).

It would be great to have this logic separated from the actual command line related code. Thanks to that we could use direct API calls as well as utilize handy parsers from CLI.

Currently all CLI results are being printed, thus the only workaround is to wrap the whole CLI and redirect method calls in context manager that redirects stdout and returns it instead.

Sniffer sniff always channel 11

Describe the bug

Sniffer catches packets from network on channel 11 when set "-c 12"

To Reproduce
Information to reproduce the behavior, including:

  1. be1cb45
  2. nRF52840-DK
  3. sudo python2 ./sniffer.py -c 12 -n 2 --rssi --no-reset -u /dev/ttyACM0 -b 250000 | wireshark -k -i -
  4. 1x OTBR, 1xFTD, 1xSniffer

Expected behavior
Wireshark must catch packets from another network

Console/log output
Initializing sniffer...
SUCCESS: sniffer initialized
Sniffing...

Additional context
Ubuntu 18.04

ImportError: cannot import name _remove_dead_weakref

I'm trying to run the sniffer per SNIFFER.md but I get an include error. I believe I followed all the steps and have all the dependencies. I noticed some of the files mentioned in the top-level have moved which makes me wonder if the .MD is out of date.

macOS 10.13.6
python 2.7.10

jberi:pyspinel ๐Ÿš€  $ python ./sniffer.py -c 11 -n 1 -u /dev/cu.usbmodem1431 | wireshark -k -i -
Traceback (most recent call last):
  File "./sniffer.py", line 34, in <module>
    import spinel.config as CONFIG
  File "/Users/jberi/code/pyspinel/spinel/config.py", line 19, in <module>
    import logging
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref

Joiner functionality does not work, joiner does not start

Describe the bug
Entering the joiner start <pskd> does not lead to the Discovery Request being send.
There is a difference in the used/expected spinel properties used for joiner configuration.

OpenThread NCP expects the SPINEL_PROP_MESHCOP_JOINER_COMMISSIONER carrying at least 'bU' with:

  • enable joiner (b)
  • PSKd (U)

In the pyspinel there is a split to two properties which seem to be written separately:

pyspinel/spinel-cli.py

Lines 1049 to 1055 in 55512b9

elif sub_command == "start":
py_format = self.prep_format(PSKd, 'U')
self.prop_set_value(SPINEL.PROP_MESHCOP_JOINER_CREDENTIAL, PSKd,
py_format)
self.prop_set_value(SPINEL.PROP_MESHCOP_JOINER_ENABLE, 1)
print("Done")
return

To Reproduce Information to reproduce the behavior, including:

  1. Connect to the NCP with the spinel-cli, e.g. python3.8 spinel-cli.py -u /dev/ttyACM0 -b 115200

  2. Enter joiner start N0RD1C

  3. See no Discovery Request sent, commissioning does not initiate from the joiner side.

  4. Git commit id: current master: 55512b9

  5. IEEE 802.15.4 hardware platform: nRF52840

  6. Build steps: OpenThread NCP FW with the JOINER=1 flag.

  7. Network topology: Single Joiner is enough to reproduce.

Expected behavior
Joiners tries to discover the network by sending the Discovery Request.

Additional context
It seems that the Commissioner functionality is completely missing.
My guess it that the joiner functionality is not used or covered by any tests and pyspinel has not been aligned after OpenThread FW changes.

debug levels > 1 should display more output

From: openthread/openthread#1479

spinel-cli.py can be assigned a higher debug level by either invoking with the "-d " flag, or passing the "debug " command into the cli shell.

None of this more advanced output is displaying however. It seems like the calls to logging.debug() are not getting routed to stdout properly.

Add an option to specify vendor module location

Is your feature request related to a problem? Please describe.

We'd like to use vendor commands with the pypi distribution of pyspinel. It seems though that it's currently not possible, as the spinel-cli loads the vendor module distributed with the package, which is just the help command.

Describe the solution you'd like

An idea is to provide an additional option to the spinel-cli (--vendor-path), which would allow to specify the location of the vendor module to load. This would allow to easily use the official pypi release of the pyspinel with custom vendor commands kept in a separate repository.

Is such an approach acceptable? If so we can handle the implementation. Would it also be possible to create a new pyspinel release for pypi once the feature is added?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.