コード例 #1
0
ファイル: fsender.c プロジェクト: LibreCrops/CopyBao
void fsender()
{
    gchar *path_utf8 = my_choose_file();
    if (path_utf8 == NULL)
        return;

    filename = g_path_get_basename(path_utf8);
    gchar *path_local = g_locale_from_utf8(path_utf8, -1, NULL, NULL, NULL);

    fp = fopen(path_local, "rb");
    g_free(path_local);
    if (!fp) {
        msgbox("Can't open file!");
	goto bad;
    }
    
    int nb = get_file_size(fp);
    if (nb > 512 * 1024) {
        msgbox("File is too big! (> 500kB)");
	goto bad2;
    }

    nbytes_remain = nb;
    nblk_sent = 0;
    nblk_total = (nb + BLKSIZE - 1) / BLKSIZE;

    start_sending();

    return;

bad2:
    fclose(fp);
bad:
    g_free(filename);
}
コード例 #2
0
ファイル: transmitter.c プロジェクト: amcinnes/pov_display
void EVENT_USB_Device_ControlRequest(void) {
    if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_INTERFACE)) {
		// Set frequency and length
		buf[0] = USB_ControlRequest.bRequest;
		Endpoint_ClearSETUP();
		start_sending(1);
		while (buf_sendpos<1) {}
		Endpoint_ClearIN();
	}
}
コード例 #3
0
ファイル: mf2_client.c プロジェクト: ohayak/tars_code
s08 mf2_client_send(char c)
{
	u16 mask, cpt=0;
	u08 flags;
	
	IRQ_LOCK(flags);

	/* we don't preempt the remote device, even if the
	   protocol allow it */
	if (!mf2_client_ready()) {
		IRQ_UNLOCK(flags);
		return -1;
	}

	state=MF2_CLIENT_STATE_XMIT;
	current_bitnum = 1;
	
	disable_intr();

	/* set clk to 0 */
	clk_0();

	IRQ_UNLOCK(flags);

	tx_buf = c;
	tx_c = c;
	tx_buf <<= 1;
	tx_buf |= STOP_BIT;

	for (mask = START_BIT ; mask != STOP_BIT; mask<<=1 ) {
		if (tx_buf & mask)
			cpt++;
	}

	if (!(cpt % 2))
		tx_buf |= PARITY_BIT;

#if CONFIG_MODULE_MF2_CLIENT_USE_SCHEDULER
	scheduler_add_single_event(start_sending, NULL, 1000L/SCHEDULER_UNIT);
#else
	wait_ms(1);
	start_sending(NULL);
#endif

	return 0;
}