0
votes

I want to generate scenario where IoT network communicate through ipv6 via Gateway Router natively mean on simulator i don't have real motes to test.

How to make linux communicate to Cooja simulator as a gateway?

1
Does this mean that you want to connect linux with the serial port of a simulated mote? - finmor
yes, i want to simulate scenario like linux can communicate to iot network via gateway node - sagar
Well, kfx's answer is what you are looking for - finmor
Thanks i got serial2pty idea about how to use it. for future reference if any tutorial related to learn contiki in deep - sagar

1 Answers

1
votes

Use serial2pty plugin: https://github.com/cmorty/cooja-serial2pty

The plugin creates a virtual serial port (pseudoterminal: PTY). You can then access that PTY as any regular serial port in Linux.

There might be a problem if the port is created dynamically - you won't know the name of the PTY device. So the plugin also includes discovery service functionality. It is a TCP server that returns the name of the PTY.

Here's Python code that can be used to get the name of the PTY using this discovery service:

    address = "localhost"
    port = 6100

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(3.0)
    sock.connect((address, port))
    data = ""
    while True:
        c = sock.recv(1)
        if c not in ['/', '.'] and not c.isalnum():
            break
        data += c
        if len(data) > 100: break
    sock.close()
    return data