File: miditest.py

package info (click to toggle)
dsmidiwifi 2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 140 kB
  • sloc: cpp: 398; python: 19; makefile: 9
file content (30 lines) | stat: -rwxr-xr-x 507 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python

import sys, os
from socket import *

# Send keepalive

host = "localhost"
port_out = 9000
port_in = 9001
buf = 1024
addr = (host, port_out)

UDPSock = socket(AF_INET,SOCK_DGRAM)

UDPSock.sendto(chr(0)+chr(0)+chr(0), addr)
UDPSock.close()

# Recv messages

addr = (host, port_in)
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)

while True:
    data,addr = UDPSock.recvfrom(buf)
    print "Got msg ",
    for i in range(len(data)):
        print "0x%02X" % ord(data[i]),
    print