Browse Source

remove dir

micha 3 years ago
parent
commit
c90527cac6
7 changed files with 0 additions and 506 deletions
  1. BIN
      old/a.out
  2. 0 160
      old/graph.py
  3. 0 80
      old/rcv.c
  4. 0 38
      old/rcv2.c
  5. 0 110
      old/send.py
  6. 0 110
      old/send2.py
  7. 0 8
      old/setup_monitor.sh

BIN
old/a.out


+ 0 - 160
old/graph.py

@@ -1,160 +0,0 @@
-
-import os
-import sys
-import fcntl  #socket control
-import socket
-import time
-
-
-
-from optparse import OptionParser
-parser = OptionParser()
-parser.add_option("-r", "--recive", dest="recive",
-                  help="set recive ip like --recive 10.")
-parser.add_option("-s", "--sendto", dest="sendto",
-                  help="set sender ip like --sendto 2.255.255.255")
-parser.add_option("-t", "--test", dest="testuniv",
-                  help="set test univers like --test [0-16]")
-parser.add_option("", "--inmap", dest="inmap",
-                  help="set test univers like --test [0-16]")
-#parser.add_option("-q", "--quiet",
-#                  action="store_false", dest="verbose", default=True,
-#                  help="don't print status messages to stdout")
-
-(options, args) = parser.parse_args()
-print("option",options)
-print(options.sendto)
-
-
-from collections import OrderedDict
-
-def unpack_art_dmx(data):
-    dmx = []
-    for i in range(len(data[18:]) ):
-        x=data[18+i]
-        #print("x",x)
-        #print( "data",b'!B', data[18+i])
-        #x=struct.unpack( b'!B',data[18+i])
-        #print( "data",b'!B', data[18+i],x)
-        #x=x[0]
-        dmx += [x]
-    return dmx
-
-import struct
-class Socket():
-    def __init__(self,bind='',port=6454):
-        self.__port =port
-        self.__bind =bind
-        self.__poll = 0
-        self.__data = []
-        self.__addr = "NONE"
-        self.head = [-1]*18 # /255 # /512  # * 512
-        self.open()
-        self._head_error = 0
-    def open(self):
-        try:
-            print("connecting to ArtNet bind:",self.__bind,"Port",self.__port)
-            self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-            
-            self.sock.bind((self.__bind, self.__port))
-            fcntl.fcntl(self.sock, fcntl.F_SETFL, os.O_NONBLOCK)
-            #self.sock.setblocking(0)
-            
-        except socket.error as e:
-            print("Socket ",self.__bind,self.__port, "ERR: {0} ".format(e.args))
-            #raw_input()
-            #sys.exit()
-    def __del__(self):
-        print( self,"head_error",self._head_error)
-    def poll(self):
-        if not self.__poll:
-            try:
-                self.__data, self.__addr = self.sock.recvfrom(self.__port)
-
-
-                data, addr = (self.__data,self.__addr)
-                self.host = addr[0]
-                head    = data[:18]
-                rawdmx  = data[18:]
-                #print([head],addr)
-                self.univ = -1
-                #print( struct.unpack("B",head) )
-                #print(type(head),[head],len(head))
-                if len(head) != 18:
-                    self._head_error += 1
-                    return 0
-                self.head = struct.unpack("!8sHBBBBHBB" , head )
-                #try:
-                #    self.head = struct.unpack("!8sHBBBBHBB" , head )
-                #except Exception as e:
-                #    pass#print( "======E09823" , e)
-                univ = self.head[6]/255 # /512  # * 512
-                self.univ = int(univ)
-                #print(univ)
-
-                if self.host.startswith("127."): #allways recive localhost on port 
-                    self.__poll = 1
-                    return 1
-                elif not options.recive:
-                    self.__poll = 1
-                    return 1
-                elif self.host.startswith(options.recive): 
-                    self.__poll = 1
-                    return 1
-                else:
-                    self.__poll = 0
-
-            except socket.timeout as e:
-                err = e.args[0]
-                if err == 'timed out':
-                    sleep(1)
-                    print('recv timed out, retry later')
-                else:
-                    print(e)
-            except socket.error as e:
-                pass
-    
-    def recive(self):
-        if self.__poll:
-            self.__poll = 0
-
-            data, addr = (self.__data,self.__addr)
-            #print( self.univ,self.head)
-
-            self.dmx  = unpack_art_dmx(data)
-
-            return { "host":self.host,"dmx":self.dmx,"univ":self.univ,"head":self.head,"data":data,"addr":addr}
-        
-
-if __name__ == "__main__":
-    x = Socket()
-    print(x)
-    sstamp = time.time()
-    xstamp = 0
-    xxstamp = 0
-    while 1:
-        if x.poll():
-            estamp = time.time()
-            xstamp = estamp-sstamp
-            xstamp = int(xstamp*10000)
-            r=x.recive()
-            #print( r["host"])
-            #print(r.keys(),r["addr"],r["univ"],r["head"])
-            flag=0
-            #if "2.0.0.14" == r["host"] and r["univ"] == 7:flag=1 
-            #if "2.0.0.1"   == r["host"] and r["univ"] == 0:flag=1
-            if r["host"].startswith("2.0.0.") and r["univ"] == 0:flag=1
-            #if r["host"].startswith("10.0.25.") :flag=1# and r["univ"] != 0:flag=1 #:flag=1
-
-            if flag:
-                string = ""
-                string += "{: 6}".format(xstamp)
-                string += "{: 6}".format(int(xstamp-xxstamp))
-                string += "{}".format(r["host"].rjust(12) )
-                string += "{: 6}".format(r["univ"])
-                string += "{:}".format(str(r["dmx"][200:221]))
-                #print("{: 6} {: 10} {} {} {}".format(xstamp,int(xstamp-xxstamp),r["host"].ljust(" ",10),r["univ"], r["dmx"][200:221] ) )
-                print(string)
-            xxstamp=xstamp
-        time.sleep(0.001)
-

+ 0 - 80
old/rcv.c

@@ -1,80 +0,0 @@
-/************* UDP CLIENT CODE *******************/
-
-#include <stdio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <string.h>
-
-#define STR(num) #num
-
-int main(){
-  int clientSocket, portNum, nBytes;
-  char buffer[1024];
-  struct sockaddr_in serverAddr;
-  socklen_t addr_size;
-
-  /*Create UDP socket*/
-  clientSocket = socket(PF_INET, SOCK_DGRAM, 6454);
-
-  /*Configure settings in address struct*/
-  //serverAddr.sin_family = AF_INET;
-  //serverAddr.sin_port = htons(7891);
-  //serverAddr.sin_port = htons(6454);
-  //serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
-  //serverAddr.sin_addr.s_addr = inet_addr("2.0.0.1");
-  //memset(serverAddr.sin_zero, '\0', sizeof serverAddr.sin_zero);  
-
-  /*Initialize size variable to be used later on*/
-  //addr_size = sizeof serverAddr;
-
-  while(1){
-    //printf("Type a sentence to send to server:\n");
-    //fgets(buffer,1024,stdin);
-    //printf("You typed: %s",buffer);
-
-    nBytes = strlen(buffer) + 1;
-    
-    /*Send message to server*/
-    //sendto(clientSocket,buffer,nBytes,0,(struct sockaddr *)&serverAddr,addr_size);
-
-    /*Receive message from server*/
-    //nBytes = recvfrom(clientSocket,buffer,1024,0,NULL, NULL);
-    nBytes = recvfrom(clientSocket,buffer,512,0,NULL, NULL);
-    //printf(": %s\n",nBytes);
-    
-    /*
-    printf(": %s\n",(&buffer));
-    
-    int i = atoi(buffer);
-    printf("%d\n", i);
-
-    int ii;
-    sscanf(buffer, "%d", &ii);
-    */
-
-    //# printf("%s\n", buffer);
-    printf(STR(buffer)": ");
-    for (int i = 0; i < 512; ++i) {
-       //printf("%c, ", buffer[i]);
-        //printf("%u, ", buffer[i]);
-        //if( i > 500 & i < 512 ){
-        printf("%i, ", buffer[i]);
-	//}
-    }
-    printf("\b\b\n");
-  
-  /*
-  unsigned int x = 0x76543210;
-  char *c = (char*) &x;
- 
-  printf ("*c is: 0x%x\n", *c);
-  if (*c == 0x10){
-    printf ("Underlying architecture is little endian. \n");
-  }else{
-    printf ("Underlying architecture is big endian. \n");
-  }
-  */
-  }
-
-  return 0;
-}

+ 0 - 38
old/rcv2.c

@@ -1,38 +0,0 @@
-/************* UDP CLIENT CODE *******************/
-
-#include <stdio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <unistd.h>
-
-#define STR(num) #num
-
-int main(){
-  int clientSocket, portNum, nBytes;
-  char buffer[530];
-  //unsigned short  buffer[512];
-  struct sockaddr_in serverAddr;
-  socklen_t addr_size;
-
-  /*Create UDP socket*/
-  clientSocket = socket(AF_INET, SOCK_DGRAM, 6454);
-
-  while(1){
-    nBytes = recvfrom(clientSocket,buffer,530,0,NULL, NULL);
-
-    printf(STR(buffer)": \n");
-    unsigned int value = 0;
-    int c = 0;
-    
-    for (int i = 0; i < 530; ++i) {
-        c |= ((0xff & value) << 24);
-        value = buffer[i];
-        printf("%02X", (char)value);
-  
-    }
-    printf("\b\b\n");
-
-  }
-  return 0;
-}

+ 0 - 110
old/send.py

@@ -1,110 +0,0 @@
-
-import time
-import socket
-import struct
-import random
-
-class ArtNetNode():
-    """simple Object to generate ArtNet Network packages 
-       works in Python2 and Python3  2021-12-05
-
-       (only basic implementation)
-
-       "Art-Net™ Designed by and Copyright Artistic Licence Holdings Ltd"
-       https://art-net.org.uk/
-    """
-    def __init__(self, to="10.10.10.255",univ=7,port=6454):
-        try: 
-            univ = int(univ)
-        except:
-            print("errror univ",univ ,"is not int ... set to 7")
-            univ = 7
-        self.univ=univ
-        self.sendto = to
-        self.portto = port
-        print(__name__,"bind",to,port,univ)
-        self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-        self.s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
-        self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-        self.stamp = time.time()
-        self.test_stamp = time.time()
-        self.dmx=[33]*512
-        self.v=0
-        self.d=1
-
-    def head(self):
-        self._header = []
-        self._header.append(b"Art-Net\x00")            # Name, 7byte + 0x00
-        self._header.append(struct.pack('<H', 0x5000)) # OpCode ArtDMX -> 0x5000, Low Byte first
-        self._header.append(struct.pack('>H', 14))     # Protocol Version 14, High Byte first
-        self._header.append(b"\x00")                   # Order -> nope -> 0x00
-        self._header.append(struct.pack('B',1))        # Eternity Port
-
-        # Address
-        #if 0 <= universe <= 15 and 0 <= net <= 127 and 0 <= subnet <= 15
-        net, subnet, universe = (0,0,self.univ) #address
-        self._header.append(struct.pack('<H', net << 8 | subnet << 4 | universe))
-
-        self._header = b"".join(self._header)
-
-    def send(self,dmx=None,port=''):
-        if dmx is None:
-            dmx = self.dmx
-        else:
-            self.dmx = dmx
-        self.head()
-        c=[self._header]
-
-        c.append( struct.pack('>H', len(dmx) ) )
-        #print([c])
-
-        dmx_count = 0
-        for v in dmx:
-            if type(v) is not int:
-                v=0
-            elif v > 255: # max dmx value 255
-                v = 255
-            elif v < 0: # min dmx value 0
-                v = 0
-            dmx_count += 1
-            c.append(struct.pack("B",v))
-        c = b"".join(c)
-        if port:
-            self.s.sendto(c, (self.sendto, port)) # default 6454
-        else:
-            self.s.sendto(c, (self.sendto, self.portto)) # default 6454
-        print(self.v)
-        time.sleep(0.0001)
-        return c
-    def _test_frame(self):
-        if self.test_stamp+(.01) < time.time():
-            self.test_stamp = time.time()
-            dmx = [0]*512
-            dmx[201-1] = self.v
-            self.dmx = dmx
-            if self.v >= 255:
-                self.d=0
-            elif self.v <=0:
-                self.d=1
-
-            if self.d:
-                self.v+=1
-            else:
-                self.v-=1
-            #print( self.v)
-        #time.sleep(1/30.)
-    def next(self):
-        if self.stamp + (1/30.) < time.time():
-            self.send()
-
-def artnet_test():
-    #artnet = ArtNetNode(to="127.0.0.1",port=6555,univ=12)
-    #artnet = ArtNetNode(to="127.0.0.1",port=6555,univ=0)
-    artnet = ArtNetNode(to="10.10.10.255",univ=0)
-    #artnet = ArtNetNode(to="10.10.10.255",univ=1)
-    while 1:
-        artnet._test_frame()
-        artnet.next()
-        time.sleep(0.01)
-
-artnet_test()

+ 0 - 110
old/send2.py

@@ -1,110 +0,0 @@
-
-import time
-import socket
-import struct
-import random
-
-class ArtNetNode():
-    """simple Object to generate ArtNet Network packages 
-       works in Python2 and Python3  2021-12-05
-
-       (only basic implementation)
-
-       "Art-Net™ Designed by and Copyright Artistic Licence Holdings Ltd"
-       https://art-net.org.uk/
-    """
-    def __init__(self, to="10.10.10.255",univ=7,port=6454):
-        try: 
-            univ = int(univ)
-        except:
-            print("errror univ",univ ,"is not int ... set to 7")
-            univ = 7
-        self.univ=univ
-        self.sendto = to
-        self.portto = port
-        print(__name__,"bind",to,port,univ)
-        self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-        self.s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
-        self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-        self.stamp = time.time()
-        self.test_stamp = time.time()
-        self.dmx=[33]*512
-        self.v=0
-        self.d=1
-
-    def head(self):
-        self._header = []
-        self._header.append(b"Art-Net\x00")            # Name, 7byte + 0x00
-        self._header.append(struct.pack('<H', 0x5000)) # OpCode ArtDMX -> 0x5000, Low Byte first
-        self._header.append(struct.pack('>H', 14))     # Protocol Version 14, High Byte first
-        self._header.append(b"\x00")                   # Order -> nope -> 0x00
-        self._header.append(struct.pack('B',1))        # Eternity Port
-
-        # Address
-        #if 0 <= universe <= 15 and 0 <= net <= 127 and 0 <= subnet <= 15
-        net, subnet, universe = (0,0,self.univ) #address
-        self._header.append(struct.pack('<H', net << 8 | subnet << 4 | universe))
-
-        self._header = b"".join(self._header)
-
-    def send(self,dmx=None,port=''):
-        if dmx is None:
-            dmx = self.dmx
-        else:
-            self.dmx = dmx
-        self.head()
-        c=[self._header]
-
-        c.append( struct.pack('>H', len(dmx) ) )
-        #print([c])
-
-        dmx_count = 0
-        for v in dmx:
-            if type(v) is not int:
-                v=0
-            elif v > 255: # max dmx value 255
-                v = 255
-            elif v < 0: # min dmx value 0
-                v = 0
-            dmx_count += 1
-            c.append(struct.pack("B",v))
-        c = b"".join(c)
-        if port:
-            self.s.sendto(c, (self.sendto, port)) # default 6454
-        else:
-            self.s.sendto(c, (self.sendto, self.portto)) # default 6454
-        print(self.v)
-        time.sleep(0.0001)
-        return c
-    def _test_frame(self):
-        if self.test_stamp+(.0010351) < time.time():
-            self.test_stamp = time.time()
-            dmx = [0]*512
-            dmx[205-1] = self.v
-            self.dmx = dmx
-            if self.v >= 255:
-                self.d=0
-            elif self.v <=0:
-                self.d=1
-
-            if self.d:
-                self.v+=3
-            else:
-                self.v-=3
-            #print( self.v)
-        #time.sleep(1/30.)
-    def next(self):
-        if self.stamp + (1/30.) < time.time():
-            self.send()
-
-def artnet_test():
-    #artnet = ArtNetNode(to="127.0.0.1",port=6555,univ=12)
-    #artnet = ArtNetNode(to="127.0.0.1",port=6555,univ=0)
-    artnet = ArtNetNode(to="10.10.10.255",univ=0)
-    #artnet = ArtNetNode(to="10.10.10.255",univ=1)
-    while 1:
-        artnet._test_frame()
-        artnet.next()
-        time.sleep(0.01)
-
-artnet_test()

+ 0 - 8
old/setup_monitor.sh

@@ -1,8 +0,0 @@
-#!/usr/bin/bash
-user="pi"
-user="micha"
-ip=17
-sudo sh /home/$user/ASP/netns.sh $ip
-
-#sudo ip netns exec blue2$ip su pi -c 'screen -d -m -S ASP_IN sh /home/user/ASP/start.sh'
-sudo ip netns exec blue2$ip su $user -c "sh /home/$user/ASP/start.sh"