Example #1
0
def gameClick(filename):
    """ Click handler for launching a game.  The pull path to the 
    game file must be passed in """
    lcdPrint("Connecting...")
    
    try:
        triforcetools.connect(ips[curr_ip], 10703)
    except:
        lcdPrint("Error:\nConnect Failed", 1)
        return

    lcdPrint("Sending...")
    lcd.setCursor(10, 0)
    lcd.ToggleBlink()

    triforcetools.HOST_SetMode(0, 1)
    triforcetools.SECURITY_SetKeycode("\x00" * 8)
    triforcetools.DIMM_UploadFile(filename)
    triforcetools.HOST_Restart()
    triforcetools.TIME_SetLimit(10*60*1000)
    triforcetools.disconnect()

    lcd.ToggleBlink()
    lcdPrint("Transfer\nComplete!", 5)
Example #2
0
import os, collections, signal, sys, subprocess, socket
import triforcetools
from time import sleep

logfile = open('log.txt', 'w')  # open input file

triforcetools.connect('192.168.0.2', 10703)
logfile.write("Sending..." + sys.argv[1])
triforcetools.HOST_SetMode(0, 1)
triforcetools.SECURITY_SetKeycode("\x00" * 8)
triforcetools.DIMM_UploadFile(sys.argv[1])
logfile.write("Transfer\nComplete!")
triforcetools.HOST_Restart()
while True:
    triforcetools.TIME_SetLimit(10 * 60 * 1000)
    sleep(5)
Example #3
0
					lcd.clear()
					lcd.ToggleBlink()
					if response == 0:
						lcd.message("Success!")
					else:
						lcd.message("Error:\nPing Failed!")
					sleep(sleep_error)
					lcd.clear()
					lcd.message(selection)
			elif selection is "Reset Target" and reset_target_available is 1:
					lcd.clear()
					lcd.ToggleBlink()
					lcd.message("Connecting...")
					#lcd.setCursor(13, 0)
					try:
						triforcetools.connect(targets_list[current_ip], 10703)
					except:
						lcd.clear()
						lcd.ToggleBlink()
						lcd.message("Error:\nConnect Failed!")
						sleep(sleep_error)
						lcd.clear()
						lcd.message(selection)
						continue
					
					lcd.clear()
					lcd.message("Resetting...")
					#lcd.setCursor(12, 0)
				
					triforcetools.HOST_SetMode(0, 1)
					triforcetools.SECURITY_SetKeycode("\x00" * 8)
Example #4
0
                lcd.clear()
                lcd.message(selection)
            else:
                GPIO.setmode(GPIO.BOARD)
                GPIO.setup(40, GPIO.OUT)
                GPIO.output(40, 1)
                sleep(0.4)
                GPIO.output(40, 0)
                lcd.clear()
                lcd.message("Hard Reset\nWait...")
                sleep(2.0)
                lcd.clear()
                lcd.message("Connecting...")

                try:
                    triforcetools.connect(ips[curr_ip], 10703)
                except:
                    lcd.clear()
                    lcd.message("Error:\nConnect Failed")
                    sleep(1)
                    lcd.clear()
                    lcd.message(selection)
                    continue

                lcd.clear()
                lcd.message("Sending...")
                lcd.setCursor(10, 0)
                lcd.ToggleBlink()

                triforcetools.HOST_SetMode(0, 1)
                triforcetools.SECURITY_SetKeycode("\x00" * 8)
Example #5
0
def manage_switch_pressed(event):
    global selection 
    global games 
    global previous
    global iterator
    global mode
    event.chip.lcd.set_cursor(16, 1)
	
    if event.pin_num == 0: #left
        event.chip.lcd.write(str(event.pin_num))
        if event.pin_num not in pressedButtons and len(games) > 0:
            pressedButtons.append(event.pin_num)
            mode      = "games"
            iterator  = iter(collections.OrderedDict(sorted(games.items(), key=lambda t: t[0])))
            selection = next(iterator)
            previous  = None
            cad.lcd.clear()
            cad.lcd.write("Games")
            sleep(1)
            cad.lcd.clear()
            cad.lcd.write(selection)            
        elif event.pin_num in pressedButtons:
            pressedButtons.remove(event.pin_num)


    elif event.pin_num == 1: #right
        event.chip.lcd.write(str(event.pin_num))
        if event.pin_num not in pressedButtons:
            pressedButtons.append(event.pin_num)
            mode      = "commands"
            iterator  = iter(commands)
            selection = next(iterator)
            previous  = None
            cad.lcd.clear()
            cad.lcd.write("Commands")
            sleep(1)
            cad.lcd.clear()
            cad.lcd.write(selection)
        elif event.pin_num in pressedButtons:
            pressedButtons.remove(event.pin_num)


    elif event.pin_num == 2: #up
        event.chip.lcd.write(str(event.pin_num))
        if event.pin_num not in pressedButtons and previous != None:
            pressedButtons.append(event.pin_num)
            if mode is "games":
                iterator = iter(collections.OrderedDict(sorted(games.items(), key=lambda t: t[0])))
            else:
                iterator = iter(commands)
            needle = next(iterator)
            selection = previous
            previous = needle
            while selection != needle and selection != previous:
                previous = needle
                try:
                    needle = next(iterator)
                except StopIteration:
                    break
            cad.lcd.clear()
            cad.lcd.write(selection)                
        elif event.pin_num in pressedButtons:
            pressedButtons.remove(event.pin_num)

    elif event.pin_num == 3: #down
        event.chip.lcd.write(str(event.pin_num))
        if event.pin_num not in pressedButtons:
            pressedButtons.append(event.pin_num)            
            previous = selection
            try:
                selection = next(iterator)
            except StopIteration:
                if mode is "games":
                    iterator = iter(collections.OrderedDict(sorted(games.items(), key=lambda t: t[0])))
                else:
                    iterator = iter(commands)
                selection = next(iterator)
            cad.lcd.clear()
            cad.lcd.write(selection)
        elif event.pin_num in pressedButtons:
            pressedButtons.remove(event.pin_num)

    elif event.pin_num == 4: #select
        event.chip.lcd.write(str(event.pin_num))
        if event.pin_num not in pressedButtons:
            pressedButtons.append(event.pin_num)
            if selection is "Change Target":
                curr_ip += 1
                if curr_ip >= len(ips):
                    curr_ip = 0
                cad.lcd.write("\n"+ips[curr_ip])
            elif selection is "Ping Netdimm":
                cad.lcd.clear()
                cad.lcd.write("Pinging\n"+ips[curr_ip])
                response = os.system("ping -c 1 "+ips[curr_ip])
                cad.lcd.clear()
                if response == 0:
                    cad.lcd.write("SUCCESS!")
                else:
                    cad.lcd.write("Netdimm is\nunreachable!")
                sleep(2)
                cad.lcd.clear()
                cad.lcd.write(selection)
            else:
                cad.lcd.clear()
                cad.lcd.write("Connecting...")
                try:
                    triforcetools.connect(ips[curr_ip], 10703)
                except:
                    cad.lcd.clear()
                    cad.lcd.write("Error:\nConnect Failed")
                    sleep(1)
                    cad.lcd.clear()
                    cad.lcd.write(selection)
                    continue
                cad.lcd.clear()
                cad.lcd.write("Sending...")
                cad.lcd.set_cursor(10, 0)
                cad.lcd.blink_on();
                triforcetools.HOST_SetMode(0, 1)
                triforcetools.SECURITY_SetKeycode("\x00" * 8)
                triforcetools.DIMM_UploadFile(rom_dir+games[selection])
                triforcetools.HOST_Restart()
                triforcetools.TIME_SetLimit(10*60*1000)
                triforcetools.disconnect()
                cad.lcd.blink_off()
                cad.lcd.clear()
                cad.lcd.write("Transfer\nComplete!")
                sleep(5)
                cad.lcd.clear()
                cad.lcd.write(selection)
    elif event.pin_num in pressedButtons:
        pressedButtons.remove(event.pin_num)

    elif event.pin_num == 5:
        event.chip.lcd.write(str(event.pin_num))
    elif event.pin_num == 6:
        event.chip.lcd.write(str(event.pin_num))
    elif event.pin_num == 7:
        event.chip.lcd.write(str(event.pin_num))
    elif event.pin_num == 8:
        event.chip.lcd.write(str(event.pin_num))
Example #6
0
                if response == 0:
                    lcd.message("SUCCESS!")
                    lcd.backlight(lcd.YELLOW)
                else:
                    lcd.message("Netdimm is\nunreachable!")
                    lcd.backlight(lcd.RED)
                sleep(2)
                lcd.clear()
                lcd.message(selection)
                lcd.backlight(lcd.YELLOW)
            else:
                lcd.clear()
                lcd.message("Connecting...")
                lcd.backlight(lcd.VIOLET)
                try:
                    triforcetools.connect(ips[curr_ip], 10703)
                except:
                    lcd.clear()
                    lcd.message("Error:\nConnect Failed")
                    lcd.backlight(lcd.RED)
                    sleep(1)
                    lcd.clear()
                    lcd.message(selection)
                    continue

                lcd.clear()
                lcd.backlight(lcd.BLUE)
                lcd.message("Sending...")
                lcd.setCursor(10, 0)
                lcd.ToggleBlink()
import triforcetools
from time import sleep
from sys import argv

if len(argv) < 3:
    print "Usage: python ./upload.py ip_address path_to_rom"
    exit()

netdimm_ip = argv[1]
rompath = argv[2]

print "Trying to connect to NetDIMM on "+netdimm_ip+"..."
while True:
    try:
        triforcetools.connect(netdimm_ip, 10703)
    except:
        pass
    
    sleep(1)

print "Uploading "+rompath+"..."
triforcetools.HOST_SetMode(0, 1)
triforcetools.SECURITY_SetKeycode("\x00" * 8)
triforcetools.DIMM_UploadFile(rompath)
triforcetools.HOST_Restart()
triforcetools.TIME_SetLimit(10*60*1000)
triforcetools.disconnect()

print "All done"
Example #8
0
#!/usr/bin/env python3

import os, triforcetools, time, sys

if len(sys.argv) != 2:
    print("NO_GAME")
    quit()

triforcetools.connect("YOUR_IP", 10703)
triforcetools.HOST_SetMode(0, 1)
triforcetools.SECURITY_SetKeycode("\x00" * 8)
triforcetools.DIMM_UploadFile(sys.argv[1])
triforcetools.HOST_Restart()
triforcetools.TIME_SetLimit(10*60*1000)
Example #9
0
                lcd.clear()
                lcd.ToggleBlink()
                if response == 0:
                    lcd.message("Success!")
                else:
                    lcd.message("Error:\nPing Failed!")
                sleep(sleep_error)
                lcd.clear()
                lcd.message(selection)
            elif selection is "Reset Target" and reset_target_available is 1:
                lcd.clear()
                lcd.ToggleBlink()
                lcd.message("Connecting...")
                #lcd.setCursor(13, 0)
                try:
                    triforcetools.connect(targets_list[current_ip], 10703)
                except:
                    lcd.clear()
                    lcd.ToggleBlink()
                    lcd.message("Error:\nConnect Failed!")
                    sleep(sleep_error)
                    lcd.clear()
                    lcd.message(selection)
                    continue

                lcd.clear()
                lcd.message("Resetting...")
                #lcd.setCursor(12, 0)

                triforcetools.HOST_SetMode(0, 1)
                triforcetools.SECURITY_SetKeycode("\x00" * 8)
import triforcetools
from time import sleep
from sys import argv

if len(argv) < 3:
    print "Usage: python ./upload.py ip_address path_to_rom"
    exit()

netdimm_ip = argv[1]
rompath = argv[2]

print "Trying to connect to NetDIMM on " + netdimm_ip + "..."
while True:
    try:
        triforcetools.connect(netdimm_ip, 10703)
    except:
        pass

    sleep(1)

print "Uploading " + rompath + "..."
triforcetools.HOST_SetMode(0, 1)
triforcetools.SECURITY_SetKeycode("\x00" * 8)
triforcetools.DIMM_UploadFile(rompath)
triforcetools.HOST_Restart()
triforcetools.TIME_SetLimit(10 * 60 * 1000)
triforcetools.disconnect()

print "All done"