Beispiel #1
0
int hw_dbus_init(void)
{
	int err;

	// init linkport
	ticable_init();
	ticable_set_param(&link_cable);
	ticable_set_cable(link_cable.link_type, &lc);
	if((err = lc.init()))
	{
		print_lc_error(err);
		return -1;
	}
	if((err = lc.open()))
	{
		print_lc_error(err);
		return -1;
	}

	// init directfile
	init_linkfile();

	// set mappers to linkport
	map_to_linkport();

    return 0;
}
Beispiel #2
0
static int lp_checkread(void)
{
	int err = 0;
	int status = 0;

	if(lp_avail_byte)
	    return 0;
	
	err = lc.check(&status);
	if(err)
	{
	    io_bit_set(0x0d,7);		// error
	    print_lc_error(err);
	    lp_last_byte = 0;
	}
  
	if(status & STATUS_RX)
	{
        err = lc.get(&lp_last_byte);
		if(err)
        {
			io_bit_set(0x0d,7);	// error
			print_lc_error(err);
        }

		io_bit_set(0x0d,5);		// rx buf full
		io_bit_set(0x0d,3);		// link activity
		lp_avail_byte = 1;
    }
	else
		lp_avail_byte = 0;
  
	return lp_avail_byte;
}
Beispiel #3
0
int hw_dbus_exit(void)
{
	int err;

	// exit linkport
	if((err = lc.close()))
	{
		print_lc_error(err);
		return -1;
	}
	if((err = lc.exit()))
	{ 
		print_lc_error(err);
		return -1;
	}
	
	// exit directfile
	exit_linkfile();

    return 0;
}
Beispiel #4
0
static void lp_putbyte(uint8_t arg)
{
	int err;
  
    err = lc.put(arg);
	if(err)
	{
		io_bit_set(0x0d,7);	// error
		print_lc_error(err);
		return;
	}
	io_bit_set(0x0d,6);		// tx buffer empty
	io_bit_set(0x0d,3);		// link activity
}
int main(int argc, char **argv)
{
	CableHandle *handle;
	int err;
	//	int i, j;
	//	uint8_t buf[65536], data;
	//	int status, result;
	//	uint8_t scr[3840 + 6];
	//	int **probing = NULL;

 #if 0
	tiTIME ref, end;
	unsigned long k;

	to_START(ref);
	for(k = 0; k < 1000000; k++) printf(" ");
	to_START(end);
	printf("%lu %lu\n", ref, end);
	printf("%lu\n", to_CURRENT(ref));
	printf("%i\n", to_ELAPSED(ref, 60));

	return 0;
#endif

	printf("USB support: %i\n", ticables_is_usb_enabled());

	// init lib
	ticables_library_init();


print_lc_error(1);

#if 0
	ticables_probing_do(&probing, 5, PROBE_ALL);
	for(i = 1; i <= 7; i++) 
		printf("%i: %i %i %i %i\n", i, probing[i][1], probing[i][2], probing[i][3], probing[i][4]);
	ticables_probing_finish(&probing);
#endif

#if 0
	{
		int *list = NULL;
		int i, n;
		int *p;

		ticables_get_usb_devices(&list, &n);
		printf("List of devices:\n");
		for(i = 0; i < n; i++)
		    printf("%i: %04x\n", i, list[i]);
	}
#endif

	// set cable
	handle = ticables_handle_new(CABLE_PAR, PORT_1);
	if(handle == NULL)
	    return -1;

	ticables_options_set_timeout(handle, 15);
	ticables_options_set_delay(handle, 10);
	ticables_handle_show(handle);

	// open cable
	err = ticables_cable_open(handle);
	if(err) print_lc_error(err);
	if(err) return -1;
#if 0
	// simple test with DirectLink hand-helds (buf size req/neg)
	buf[0]=0x00; buf[1]=0x00; buf[2]=0x00; buf[3]=0x04;
	buf[4]=0x01;
	buf[5]=0x00; buf[6]=0x00; buf[7]=0x04; buf[8]=0x00;
	err = ticables_cable_send(handle, buf, 9);
        if(err) print_lc_error(err);

	// display answer
	memset(buf, 0, sizeof(buf));
	err = ticables_cable_recv(handle, buf, 9);
	if(err) print_lc_error(err);

	for(i = 0; i < 9; i++)
	    printf("%02x ", buf[i]);
	printf("\n");
#endif

#if 0
	// mode set
	i = 0;
	buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x10;
	buf[i++]=0x04;
	buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x0a;
	buf[i++]=0x00; buf[i++]=0x01;
	buf[i++]=0x00; buf[i++]=0x03; 
	buf[i++]=0x00; buf[i++]=0x01;
	buf[i++]=0x00; buf[i++]=0x00; 
	buf[i++]=0x00; buf[i++]=0x00; 
	buf[i++]=0x07; buf[i++]=0xd0;

	err = ticables_cable_send(handle, buf, i);
	if(err) print_lc_error(err);

	err = ticables_cable_recv(handle, buf, 7);
	if(err) print_lc_error(err);
	for(i = 0; i < 7; i++)
	    printf("%02x ", buf[i]);
	printf("\n");

	// mode ack
	err = ticables_cable_recv(handle, buf, 15);
	if(err) print_lc_error(err);
	for(i = 0; i < 15; i++)
		printf("%02x ", buf[i]);
	printf("\n");

	i = 0;
	buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02;
	buf[i++]=0x05;
	buf[i++]=0xe0; buf[i++]=0x00;

	err = ticables_cable_send(handle, buf, i);
	if(err) print_lc_error(err);
	PAUSE(500);
#endif

#if 0
	// param req (TI84+ only)
	i = 0;
	buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0xa;
	buf[i++]=0x04;
	buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x04;
	buf[i++]=0x00; buf[i++]=0x07;
	buf[i++]=0x00; buf[i++]=0x01; 
	buf[i++]=0x00; buf[i++]=0x22;

	err = ticables_cable_send(handle, buf, i);
	if(err) print_lc_error(err);

	err = ticables_cable_recv(handle, buf, 7);
	if(err) print_lc_error(err);
	for(i = 0; i < 7; i++)
		printf("%02x ", buf[i]);
	printf("\n");

	// delay ack
	err = ticables_cable_recv(handle, buf, 15);
	if(err) print_lc_error(err);
	for(i = 0; i < 15; i++)
	    printf("%02x ", buf[i]);
	printf("\n");

	i = 0;
	buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02;
	buf[i++]=0x05;
	buf[i++]=0xe0; buf[i++]=0x00;

	err = ticables_cable_send(handle, buf, i);
	if(err) print_lc_error(err);

	// param data
	for(j = 0; j < 3; j++)
	{
		err = ticables_cable_recv(handle, buf, 255);
		if(err) print_lc_error(err);
		for(i = 0; i < 16; i++)
			printf("%02x ", buf[i]);
		printf("\n");

		i = 0;
		buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02;
		buf[i++]=0x05;
		buf[i++]=0xe0; buf[i++]=0x00;

		err = ticables_cable_send(handle, buf, i);
		if(err) print_lc_error(err);
	}
	{
		err = ticables_cable_recv(handle, buf, 36);
		if(err) print_lc_error(err);
		for(i = 0; i < 16; i++)
			printf("%02x ", buf[i]);
		printf("\n");

		i = 0;
		buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02;
		buf[i++]=0x05;
		buf[i++]=0xe0; buf[i++]=0x00;

		err = ticables_cable_send(handle, buf, i);
		if(err) print_lc_error(err);
	}
	PAUSE(500);
#endif

#if 0
	// do a simple test with a TI89/92+ calculator
	buf[0] = 0x08; buf[1] = 0x68; buf[2] = 0x00; buf[3] = 0x00;	// RDY
	err = ticables_cable_send(handle, buf, 4);
	if(err) print_lc_error(err);
	 
	// display answer
	memset(buf, 0xff, 4);
	err = ticables_cable_recv(handle, buf, 4);
	if(err) print_lc_error(err);

	for(i = 0; i < 4; i++)
		printf("%02x ", buf[i]);
	printf("\n");
#endif

#if 0
	// do a screendump
	buf[0] = 0x08;  buf[1] = 0x6D; buf[2] = 0x00; buf[3] = 0x00;	// SCR
	err = ticables_cable_send(handle, buf, 4);
	if(err) print_lc_error(err);
	
	memset(buf, 0xff, 4);
	err = ticables_cable_recv(handle, buf, 4);	// ACK
	if(err) print_lc_error(err);

	err = ticables_cable_recv(handle, scr, 0x0f00 + 6);	// XDP
	if(err) print_lc_error(err);
	printf("%02x %02x\n", scr[2], scr[3]);

	buf[0] = 0x08;  buf[1] = 0x56; buf[2] = 0x00; buf[3] = 0x00;	// ACK
	err = ticables_cable_send(handle, buf, 4);
	if(err) print_lc_error(err);
#endif

#if 0
	// simple test for data arrival detection
	buf[0] = 0x08;  buf[1] = 0x87; buf[2] = 'A'; buf[3] = 0x00;		// KEY
	err = ticables_cable_send(handle, buf, 4);
	if(err) print_lc_error(err);

	for(status = 0; !status;)
	{
		err = ticables_cable_check(handle, &status);
		if(err) print_lc_error(err);
	}

	// display answer
	memset(buf, 0xff, 4);
	err = ticables_cable_recv(handle, buf, 4);
	if(err) print_lc_error(err);

	for(i = 0; i < 4; i++)
		printf("%02x ", buf[i]);
	printf("\n");
#endif

#if 0
	for(status = 0; !status;)
	{
	    //fprintf(stdout, "$\n");
	    //fflush(stdout);
		err = ticables_cable_check(handle, &status);
		if(err) print_lc_error(err);
	}

	// display answer
	memset(buf, 0xff, 4);
	err = ticables_cable_recv(handle, buf, 4);
	if(err) print_lc_error(err);

	for(i = 0; i < 4; i++)
		printf("%02x ", buf[i]);
	printf("\n");
#endif

	// close cable
	ticables_cable_close(handle);
	// release handle
	ticables_handle_del(handle);
	
	// exit lib
	ticables_library_exit();
#ifdef __WIN32__
	while(!kbhit());
#endif
	return 0;
}
Beispiel #6
0
int send_ti_file(const char *filename)
{
    gint ok = 0;
	int ret;

    // Check for TI file
    if(!tifiles_is_a_ti_file(filename))
        return ERR_68K_TI_FILE;

    if(((tifiles_which_calc_type(filename) == CALC_TI89) && (tihw.calc_type == TI89)) ||
        ((tifiles_which_calc_type(filename) == CALC_TI92) && (tihw.calc_type == TI92)) ||
        ((tifiles_which_calc_type(filename) == CALC_TI92P) && (tihw.calc_type == TI92p)) ||
        ((tifiles_which_calc_type(filename) == CALC_V200) && (tihw.calc_type == V200)))
    {
        ok = 1;
    } else
        return ERR_68K_TI_FILE;

    t2f_flag = 0;
    f2t_flag = 0;

    // FLASH APP file ?
    if(tifiles_is_a_flash_file(filename) && !strcasecmp(tifiles_flash_app_file_ext(), tifiles_get_extension(filename)))
    {
        map_to_directfile();
        tihw.lc_speedy = 1;
        ret = itc.send_flash(filename, MODE_APPS);
        tihw.lc_speedy = 0;
        map_to_linkport();
    }

    // FLASH OS file ?
    if(tifiles_is_a_flash_file(filename) && !strcasecmp(tifiles_flash_os_file_ext(), tifiles_get_extension(filename)))
    {
        map_to_directfile();
        tihw.lc_speedy = 1;
        ret = itc.send_flash(filename, MODE_AMS);
        tihw.lc_speedy = 0;
        map_to_linkport();
    }
  
    // Backup file ?
    else if(tifiles_is_a_backup_file(filename))
    {
        map_to_directfile();
        tihw.lc_speedy = 1;
        ret = itc.send_backup(filename, MODE_NORMAL);
        tihw.lc_speedy = 0;
        map_to_linkport();
    }

    // Group file ?
    else if(tifiles_is_a_group_file(filename))
    {
        map_to_directfile();
        tihw.lc_speedy = 1;
        ret = itc.send_var(filename, MODE_NORMAL, NULL);
        tihw.lc_speedy = 0;
        map_to_linkport();
    }

    // Single file
    else if(tifiles_is_a_single_file(filename))
    {
        map_to_directfile();
        tihw.lc_speedy = 1;
        ret = itc.send_var(filename, MODE_NORMAL, NULL);
        tihw.lc_speedy = 0;
        map_to_linkport();
    }

	// Transfer aborted ? Set hw link error
	if(ret != 0)
	{
		print_lc_error(ret);
		io_bit_set(0x0d,7);
	}

  return 0;
}