Ejemplo n.º 1
0
void ___openinterfaces()
{
	if (!IDOS)
		IDOS = (struct DOSIFace *)OpenInterface("dos.library", 53);
	if (!IUtility)
		IUtility =
		    (struct UtilityIFace *)OpenInterface("utility.library", 53);
}
Ejemplo n.º 2
0
int   main(int argc,char *argv[])
{
   FILE  *f;
   if(argc>=2)
   {
      f=fopen(argv[1],"r");
      if(f==NULL)
      {
         perror(argv[1]);
         return(1);
      }
      Load(f);
      fclose(f);
   }
   else
   {
      f=fopen("field.lif","r");
      if(f!=NULL)
      {
         Load(f);
         fclose(f);
      }
   }

   OpenInterface();
   OwInitialize(root_pal);
   ShowMouse(TRUE);
   SetEventMask(KEYBOARD_EVENTS|MOUSE_EVENTS);
   OwCreate(&StatusWin,0,DOWN,1,1,status_pal);
   OwCreate(&ReadLine,MIDDLE,MIDDLE+5,60,4,readline_pal);
   Life();
   OwExit();
   CloseInterface();
   return(0);
}
Ejemplo n.º 3
0
void ___makeenviron()
{
	struct Hook hook;

	char varbuf[8];
	uint32 flags = 0;

	struct DOSIFace *myIDOS =
	    (struct DOSIFace *)OpenInterface("dos.library", 53);
	if (myIDOS)
	{
		if (myIDOS->GetVar("ABCSH_IMPORT_LOCAL", varbuf, 8,
		                   GVF_LOCAL_ONLY) > 0)
		{
			flags = GVF_LOCAL_ONLY;
		}
		else
		{
			flags = GVF_GLOBAL_ONLY;
		}

		hook.h_Entry = size_env;
		hook.h_Data = 0;

		myIDOS->ScanVars(&hook, flags, 0);
		hook.h_Data = (APTR)(((uint32)hook.h_Data) + 1);

		myenviron = (char **)IExec->AllocVec((uint32)hook.h_Data *
		                                     sizeof(char **),
		                                     MEMF_ANY | MEMF_CLEAR);
		origenviron = myenviron;
		if (!myenviron)
		{
			return;
		}
		hook.h_Entry = copy_env;
		hook.h_Data = myenviron;

		myIDOS->ScanVars(&hook, flags, 0);
		CloseInterface((struct Interface *)myIDOS);
	}
}
Ejemplo n.º 4
0
void ___freeenviron()
{
	char **i;
	/* perl might change environ, it puts it back except for ctrl-c */
	/* so restore our own copy here */
	struct DOSIFace *myIDOS =
	    (struct DOSIFace *)OpenInterface("dos.library", 53);
	if (myIDOS)
	{
		myenviron = origenviron;

		if (myenviron)
		{
			for (i = myenviron; *i != NULL; i++)
			{
				IExec->FreeVec(*i);
			}
			IExec->FreeVec(myenviron);
			myenviron = NULL;
		}
		CloseInterface((struct Interface *)myIDOS);
	}
}
void
DataGloveLogger::Publish()
{
	char definition[32];

	m_enabled = ( ( int )OptionalParameter( "LogDataGlove" ) != 0 );
	if( !m_enabled ) return;

	OpenInterface();
	int nGloves = CountGloves(); // needed in order to know how many states to declare.
	string h;
	if(nGloves == 1) { // if 1 glove is connected, since we have this info, helpfully set the "default" value of DataGloveHandedness to the correct value
		DataGloveThreadList g;
		GetGloves(g);
		h = ((g.back()->GetHandedness() == FD_HAND_LEFT) ? "L" : "R");
		EmptyList(g);
	}

	for(int iGlove = 0; iGlove < nGloves; iGlove++) {
		if(nGloves > 1)
			h = ((iGlove%2)?" L ":" R ") + h; // If an even number of gloves is attached, the helpful default will end up as L R L R... If an odd number of gloves > 1 is attached, it will end up as R L R .... 
		for(int iSensor = 0; iSensor < MAX_SENSORS; iSensor++) {
			sprintf(definition, "Glove%dSensor%02d %d 0 0 0", iGlove+1, iSensor+1, SENSOR_PRECISION);
			BEGIN_EVENT_DEFINITIONS
				definition,
			END_EVENT_DEFINITIONS
		}
	}
	sprintf(definition, "%d", nGloves);
	h = "Source:Log%20Input list    DataGloveHandedness= " + (definition+h) + " // DataGlove handedness: L or R for each glove";
	BEGIN_PARAMETER_DEFINITIONS
		"Source:Log%20Input int     DataGloveDerivative=   0    0  0 1 // measure changes in glove signals?: 0: no - measure position, 1:yes - measure velocity (enumeration)",
		"Source:Log%20Input int     LogDataGlove=          0    0  0 1 // record DataGlove to states (boolean)",
		h.c_str(), // "Source:Log%20Input list    DataGloveHandedness= 1 L    R  % % // DataGlove handedness: L or R for each glove",
	END_PARAMETER_DEFINITIONS
}
Ejemplo n.º 6
0
int main (int argc, const char * argv[]) {
    UInt32 addr = 0;
    UInt8 config = 0;
    USBDevice device;
    USBInterface iface;
    dload_action action = kDLoadNone;
    
    printf("Starting DLOADTool\n");
    if(argc >= 1) {
        if(strcmp(argv[1], "-c") == 0) {
            // Send custom packets
            action = kDLoadSend;
            
        } else if(strcmp(argv[1], "-f") == 0) {
            // Upload firmware file
            action = kDLoadUpload;
            
        } else {
            // Upload dbl
            action = kDLoadNone;
        }
    } else {
        printf("Usage: %s [-f firmware] [-c command1 command2 ... commandN]\n", argv[0]);
        return -1;
    }
    
    //Vendor ID: 0x5c6
    //Product ID: 0x9008
    device = OpenDevice(0x5c6, 0x9008);
    if(device) {
        printf("Device Opened\n");
        config = SetConfiguration(device, 1);
        if(config == 1) {
            printf("Configuration %hhx set\n", config);
            iface = OpenInterface(device, 0, 0);
            if(iface) {
                printf("Interface Opened\n");
                
                if(action == kDLoadSend && argc >= 3) {
                    int i = 0;
                    int v = 0;
                    unsigned char input[0x200];
                    unsigned char output[0x200];
                    for(v = 2; v < argc; v++) {
                        const char* arg = (const char*) argv[v];
                        unsigned int size = strlen(arg) / 2;
                        memset(output,'\0', sizeof(output));
                        memset(input, '\0', sizeof(input));
                        for(i = 0; i < size; i++) {
                            unsigned int byte = 0;
                            sscanf(arg, "%02x", &byte);
                            output[i] = byte;
                            arg += 2;
                        }
                        dload_write(iface, output, size);
                        dload_read(iface, input, sizeof(input));
                    }
                }
                
                if(action == kDLoadUpload && argc == 3) {
                    addr = 0x20012000;
                    dload_get_params(iface);
                    dload_get_sw_version(iface);
                    dload_upload_firmware(iface, addr, argv[2]);
                    dload_send_execute(iface, addr);
                }
                
                if(action == kDLoadNone && argc == 1) {
                    addr = 0x20012000;
                    dload_get_params(iface);
                    dload_get_sw_version(iface);
                    dload_upload_firmware(iface, addr, "/usr/local/standalone/firmware/Trek/dbl.mbn");
                    dload_send_execute(iface, addr);
                }
                
                printf("Closing Interface\n");
                CloseInterface(iface);
                
            } else {
                fprintf(stderr, "Couldn't open device interface\n");
            }
        }
        
        
        CloseDevice(device);
    }

    return 0;
}