Skip to content

Commit

Permalink
Add routing helper script
Browse files Browse the repository at this point in the history
Allows for a normal network interface provided that the ip range is not
192.168.1.X. Deffault is 192.168.2.X
  • Loading branch information
rolandoislas committed Sep 16, 2016
1 parent 6de968c commit 54bd175
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drc-sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def udp_service(ip, port):

# hack for now, replace with dhcp result
WII_LOCAL_IP = '192.168.1.11'
OUT_LOCAL_IP = '127.0.0.1'
OUT_LOCAL_IP = '0.0.0.0'

WII_MSG_S = udp_service(WII_LOCAL_IP, WII_PORT_MSG)
WII_VID_S = udp_service(WII_LOCAL_IP, WII_PORT_VID)
Expand Down Expand Up @@ -544,7 +544,7 @@ def scale_stick(OldValue, OldMin, OldMax, NewMin, NewMax):
report[0x3f] = 0xe000
#print report.tostring().encode('hex')
WII_HID_S.sendto(report, ('192.168.1.10', WII_PORT_HID))
hid_seq_id += 1
#hid_seq_id += 1

EVT_SEND_HID = pygame.USEREVENT
pygame.time.set_timer(EVT_SEND_HID, int((1. / 180.) * 1000.))
Expand Down
35 changes: 35 additions & 0 deletions util/route.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Wii NIC
wiiface="wlx687f747d2e59"

# Normal NIC
interface="eth0"
ip="192.168.2.137"
subnet="192.168.2.0/24" # subnet? terminology might be wrong
gateway="192.168.2.1"

# These are for the Wii U and gamepad.
# They appear to be static but here Justin Case.
WII_LOCAL_IP="192.168.1.11"
WII_SUBNET="192.168.1.0/24"
WII_GATEWAY="192.168.1.1"

# Assign an ip to the interface.
sudo ifconfig $wiiface $WII_LOCAL_IP

# This creates two different routing tables, that we use based on the source-address.
sudo ip rule add from $ip table 1
sudo ip rule add from $WII_LOCAL_IP table 2

# Configure the two different routing tables
sudo ip route add $subnet dev $interface scope link table 1
sudo ip route add default via $gateway dev $interface table 1

sudo ip route add $WII_SUBNET dev $wiiface scope link table 2
sudo ip route add default via $WII_GATEWAY dev $wiiface table 2

# default route for the selection process of normal internet-traffic
sudo ip route add default scope global nexthop via $gateway dev $interface

# Setup dhcp
sudo dhclient
5 changes: 4 additions & 1 deletion test-stream.py → util/test-stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import socket
import sys

IP = "127.0.0.1"
IP = "0.0.0.0"
VIDEO_PORT = 50000

pygame.init()
screen = pygame.display.set_mode((854, 480))
pygame.display.set_caption("test-stream")
clock = pygame.time.Clock()

while True:
for event in pygame.event.get():
Expand All @@ -28,3 +29,5 @@
image = pygame.image.fromstring(imageBuffer, (854, 480), "RGB")
screen.blit(image, (0, 0))
pygame.display.flip()
clock.tick()
pygame.display.set_caption("test-stream - fps: " + str(round(clock.get_fps())))

0 comments on commit 54bd175

Please sign in to comment.