Raw data access

241 views
Skip to first unread message

Ben van der Pluijm

unread,
Sep 10, 2018, 9:40:50 AM9/10/18
to RaspberryShake
How can I access the count data of a connected RS?  We'd like to do local processing, which requires timed, raw counts.

tinotenaz

unread,
Sep 11, 2018, 8:59:29 AM9/11/18
to RaspberryShake
Hi,

you can use the Raspberry Shake’s SeedLink server on port 18000 which is a real-time data server. There you can get the raw data.

if you use SeisComP3 you can use slinktool 

slinktool -Q raspberryshake.local:18000

Cheers.

Richard

unread,
Sep 11, 2018, 9:20:17 AM9/11/18
to RaspberryShake
hi ben,

you can also have the data sent off the shake Pi computer via UDP to another computer for local processing.

see here for details:


richard

Juan Antonio

unread,
Oct 21, 2018, 5:41:03 PM10/21/18
to RaspberryShake
Hello

I´m trying to take advance of all ideas launched in this blog  to read raw data of raspberryshake and send it to other computer, but i´m not able to communicate raspberryshake with my Laptop (windows) via UDP ports as raspberryshake manual indicates. 

Both computers are in the same home network and I can interact rightly with my RaspberryShake frontend from my laptop, connect via swarm, WINSCP, putty, etc. But I´m not able to detect data in my laptop coming from Shake. I have opened an UDP port (i test with several ports 18002, 18000, 2399, etc.) in my router and windows firewall. 

Some tests I made without success are:
  • Case 1. Using netcat commands to send simple messages between Rpi Shake and Laptop  in order to validate the basic connection via UDP ports.
$ nc -u -l 2399 (in windows cmd console  in order to listen)
               
$ nc -u 192.168.1.5 2399 (in Raspberry Shake, via putty, in order to send a Hello message)
              Hello  
             
             
           Result: No message arrives to my command line of windows laptop. 
 
  
Case 2. Executing  \opt\settings\user\shake-UDP-remote.py as you can see

import socket as s

host = "192.168.1.35" #when running not on the Shake Pi: blank = localhost 
port = 18002 # Port to bind to

HP = host + ":" + str(port)
print "  Opening socket on (HOST:PORT)", HP

sock = s.socket(s.AF_INET, s.SOCK_DGRAM | s.SO_REUSEADDR)
sock.bind((host, port))

print "Waiting for data on (HOST:PORT) ", HP

while 1: # loop forever
    data, addr = sock.recvfrom(1024) # wait to receive data
    print data

Result: 

Opening socket on (HOST:PORT) 192.168.1.35:18002
Traceback (most recent call last):
  File "shake-UDP-remote.py", line 10, in <module>
    sock.bind((host, port))
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address

 Case 3. Configuring  \opt\settings\user\UDP-data-streams.conf and trying to read , (using node red with UDP node as another thread propose) if something is coming in this port
{
    "UDP-destinations" : [
        { "dest" : "UDP-1"},
        { "dest" : "UDP-2"}
    ],
    
    "UDP-1" : {
        "Hostname" : "UDPIPFILE:/opt/settings/sys/ip.txt",
        "Port" : "8888"
    },

    "UDP-2" : {
        "Hostname" : "192.168.1.35",
        "Port" : "18002"
    }
}
 

Result: In debug Node UDP 
 
21/10/2018 23:22:21node: 4ea77c9d.6756e4
msg : string[25]
"udp: port already in use"


Can someone tell me if is there a simple way to test that communication between both computers through UDP ports are working?. To tell true, i´am autodidact in this communication subjects and I´m a little lost.  


Thanks
Regards

Juan Antonio

Ian Nesbitt

unread,
Oct 22, 2018, 9:48:49 AM10/22/18
to RaspberryShake
Hi Juan,

Well, I'm not familiar enough with netcat (or the windows shell) to diagnose the error you describe in case 1, but I think I know why the python program in case 2 is failing at least.

We aren't as clear as we could be in the manual about this: for the purposes of this discussion, you can only open UDP ports on your local machine. That means the host line can only be localhost, or else you'll run into a permissions error. UDP is really only a one-way communication method. TCP, the most widely understood form of internet communication, is a request-based protocol, while UDP is more like a firehose of data. You can turn it on and off from the Shake end, but you can't really "ask" for it from the receiving end like you would with TCP. (read here in the manual: https://manual.raspberryshake.org/udp.html#preamble-udp-versus-tcp-protocols)

This means your python program should look like this on the receiving end:

import socket as s

host
= ""              # blank = localhost (you are on the receiving end)
port
= 18002           # port the Shake sends data to


HP
= host + ":" + str(port)
print " Opening socket on (HOST:PORT)", HP

sock
= s.socket(s.AF_INET, s.SOCK_DGRAM | s.SO_REUSEADDR)
sock
.bind((host, port))

print "Waiting for data on (HOST:PORT) ", HP

while 1: # loop forever
 data
, addr = sock.recvfrom(1024) # wait to receive data
 
print data

Meanwhile, over at the Shake, your UDP configuration at /opt/settings/user/UDP-data-streams.conf will look like this (assuming your computer is on the same network and its IP is 192.168.1.5):

{
   
"UDP-destinations" : [
       
{ "dest" : "YOURCOMPUTER"}
   
],


   
"YOURCOMPUTER" : {
       
"Hostname" : "192.168.1.5",
       
"Port" : "18002"
   
}
}

The other thing that could be a roadblock is that you may have several programs trying to open the same UDP port, when only one can connect to a port at a time. I could be wrong about this but I think you have to quit out of NodeRED when using Python and vice versa. Sometimes these programs will leave the socket open even if you think you've quit out of them, in which case the easiest thing may be to reboot.

I'm making a couple of assumptions about your computer's IP and the fact that it and the Shake are on the same network, which you should fact check me on, but does this clarify things?

Ian

Ian Nesbitt

unread,
Oct 22, 2018, 9:53:33 AM10/22/18
to RaspberryShake
In other words, I think the Shake was pointing the firehose of UDP data back at itself, when it should be pointing that data towards your computer, and your computer should be listening on its own port!

And, I think your NodeRED error was caused by python already listening on that port and therefore locking out all other programs.

Ian

Juan Antonio

unread,
Oct 22, 2018, 6:39:11 PM10/22/18
to RaspberryShake
Thank you Ian for your time and patience.

 

Both computers (RpiShake and laptop) are in the same network (home) connected to a router by dongle wifi.  

 

Your answer clarify some wrong ideas, I have, but after I execute (in spyder on anaconda with python 3.6) your code recommendation it appear another error; similar to reported in “Plotting UDP data live” thread By Graham.  “OSError: [WinError 10044] The support for the specified socket type does not exist in this address family”, but in Spanish (OSError: [WinError 10044] No existe compatibilidad para el tipo de socket especificado en esta familia de direcciones).

 

Then I tested to execute Richard code recommendation to Graham (below), but I don’t detect any data sended (“Hello, World”) in Terminal IPython of receiver.

  

code to receive UDP data

==== BEGIN CODE SNIPPET ====

import socket

 

UDP_IP = "127.0.0.1"

UDP_PORT = 5005

 

sock = socket.socket(socket.AF_INET, # Internet

                     socket.SOCK_DGRAM) # UDP

sock.bind((UDP_IP, UDP_PORT))

 

while True:

    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes

    print "received message:", data

==== END CODE SNIPPET ====


and the code to send a UDP message:

==== BEGIN CODE SNIPPET ====

import socket

 

UDP_IP = "127.0.0.1"

UDP_PORT = 5005

MESSAGE = "Hello, World!"

 

print "UDP target IP:", UDP_IP

print "UDP target port:", UDP_PORT

print "message:", MESSAGE

 

sock = socket.socket(socket.AF_INET, # Internet

                     socket.SOCK_DGRAM) # UDP

sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

==== END CODE SNIPPET ====

 

I´ll try to test other possibilities, I studied carefully 3 threads related with this subject and manual.(Accessing data on Shake, Plotting UDP data live and

·          Raw data Access)

 

Any other Idea to test?

 

Regards.

Ian Nesbitt

unread,
Oct 23, 2018, 11:35:04 AM10/23/18
to RaspberryShake
Juan,

Try this. On your laptop, open up two Anaconda Prompt windows right next to each other. I'm assuming you're running python 3 but this should work in python 2 as well. Type ipython into both windows. This will take you to the ipython prompt.

The first window will be your "receiving" window. Copy/paste the following code into it:

import socket

UDP_IP
= "127.0.0.1"     # localhost

UDP_PORT
= 5005


sock
= socket.socket(socket.AF_INET, # Internet
                     socket
.SOCK_DGRAM) # UDP

sock
.bind((UDP_IP, UDP_PORT))


while True:
    data
, addr = sock.recvfrom(1024) # buffer size is 1024 bytes

   
print("received message:", data)

In the second window, the "sending" window, copy and paste this code:

import socket

UDP_IP
= "127.0.0.1"
UDP_PORT
= 5005

MESSAGE
= b"Hello world"

print("UDP target IP:", UDP_IP)
print("UDP target port:", UDP_PORT)
print("message:", MESSAGE)


sock
= socket.socket(socket.AF_INET, # Internet
                     socket
.SOCK_DGRAM) # UDP

sock
.sendto(MESSAGE, (UDP_IP, UDP_PORT))

Copy and paste the output here so I can see what's happening.

Ian

Juan Antonio

unread,
Oct 23, 2018, 4:48:13 PM10/23/18
to RaspberryShake
Hello Ian

The message sended was received rightly. 

Does this means that there is not compatibilty problem with socket.SOCK_DGRAM?. 

What could be the next step?

Thanks 
Regards  


Hello message received.png

Hello message received.png

Branden Christensen

unread,
Mar 11, 2019, 10:45:48 PM3/11/19
to RaspberryShake
FYI: In ver.15 all of this has been moved to rs.local (which replaces raspberryshake.local), removing the need to configure UDP streaming from the command-line.



Kind Regards from Panama,


Branden Christensen
CEO, Raspberry Shake, Social Media: @raspishake

"Vive a tu manera" - Herencia de Timbiquí


--
Some useful links:
 
Manual: http://manual.raspberryshake.org/
Do It YourSelf Page: http://raspberryshake.org/do-it-yourself
Shop: https://shop.raspberryshake.org/
Website: http://raspberryshake.org/
 
Instagram: https://www.instagram.com/raspishake/
Facebook: https://www.facebook.com/raspishake/
Twitter: https://twitter.com/raspishake/
Hashtag: #rasperryshake, @raspishake
DOI: https://doi.org/10.7914/SN/AM
---
You received this message because you are subscribed to the Google Groups "RaspberryShake" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raspberryshak...@googlegroups.com.
To post to this group, send email to raspber...@googlegroups.com.
Visit this group at https://groups.google.com/group/raspberryshake.
To view this discussion on the web visit https://groups.google.com/d/msgid/raspberryshake/de983df9-2405-4388-98f0-9a83c956aa05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Juan Antonio

unread,
Mar 12, 2019, 8:29:22 PM3/12/19
to RaspberryShake
Thanks Branden. It´s a good new. I gave up this subject after a lot of tests, but i´ll try with this option. 

Regards
Juan Antonio  
Reply all
Reply to author
Forward
0 new messages