示例#1
0
void SerialConnection::SendNMEAMessage( wxString &message, wxString &source )
{
    if ( !IsOpen() )
        return;
    if ( FilterOutput( message, source ) )
    {
        wxCharBuffer buffer = message.ToAscii();
        WriteDevice( buffer.data(), strlen( buffer.data() ) );
        buffer = m_EOS.ToAscii();
        WriteDevice( buffer.data(), strlen( buffer.data() ) );
    }
}
示例#2
0
文件: term.c 项目: andrewpines/lpcisp
static void DoTasks(int fd)
{
	int
		processID;

	processID=fork();
	if(processID>=0)
	{
		if(processID)				// =0 for the child, =PID of the child for the parent
		{
			WriteDevice(TTYIN,fd);	// will run until done=true
			if(kill(processID,SIGKILL)<0)
			{
				ReportString(REPORT_ERROR,"terminal: failed to kill sub-task\n");
			}
		}
		else
		{
			ReadDevice(fd,TTYOUT);		// child task, will run until done=true
		}
	}
	else
	{
		ReportString(REPORT_ERROR,"terminal: failed to fork\n");
	}
}
示例#3
0
bool afx_raw(unsigned char cmd[DATA_LENGTH]) {
	unsigned char chk[DATA_LENGTH];
	memcpy(chk,cmd,DATA_LENGTH);
	WriteDevice(cmd,DATA_LENGTH);
	//	usleep(DEFAULT_USB_SLEEP);
	if (memcmp(chk,cmd,DATA_LENGTH)) printf("AFX: OK\n"); else printf("AFX: ERR\n");
}
OMX_ERRORTYPE VideoRender::RenderFrame(
        OMX_BUFFERHEADERTYPE *pBufferHdr)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    Report2VideoVisitors(pBufferHdr);
    WriteDevice(pBufferHdr);
    return ret;
}
示例#5
0
int SetDelay(libusb_device_handle *alienfx, unsigned int delay)
// delay = [MIN_SPEED, MAX_SPEED], but it's a delay 
{
    delay = CageInt(MIN_SPEED, delay, MAX_SPEED);
    delay = (delay / STEP_SPEED) * STEP_SPEED; // quantize to step multiple 
    unsigned char b1 = (delay >> 8) & 0xff;
    unsigned char b2 = (delay >> 0) & 0xff;
    
    unsigned char data[] = { START_BYTE, COMMAND_SET_SPEED, b1, b2 };
    return WriteDevice(alienfx, &data[0], sizeof data);
}
示例#6
0
int Reset(libusb_device_handle *alienfx, int reset_type)
{
    /* reset_type must be one of:
     *   RESET_CONTROLS_ON
     *   RESET_SLEEP_LIGHTS_ON
     *   RESET_ALL_LIGHTS_OFF
     *   RESET_ALL_LIGHTS_ON
     */
    unsigned char data[] = { START_BYTE, COMMAND_RESET,
                             (unsigned char)reset_type };
    return WriteDevice(alienfx, &data[0], sizeof data);
}
示例#7
0
void
WriteConfig (const char *path, Device * d)
{
  if (!d)
    die (_("nothing to write"));

  FILE *f = fopen (path, "w");
  if (!f)
    die (_("writing to %s failed"), path);

  WriteDevice (f, *d);

  fclose (f);
}
示例#8
0
int ColorSet(libusb_device_handle *alienfx, int block, int region,
             int r, int g, int b)
{
    unsigned char green = (g >> 4) & 0x0f; // only used within red_green 
    unsigned char red   = (r >> 0) & 0xf0; // only used within red_green 
    unsigned char blue  = (b >> 0) & 0xf0;
    unsigned char red_green = red | green;

    unsigned char reg1 = (unsigned char)(((unsigned int)region >> 16) & 0xff);
    unsigned char reg2 = (unsigned char)(((unsigned int)region >>  8) & 0xff);
    unsigned char reg3 = (unsigned char)(((unsigned int)region >>  0) & 0xff);

    unsigned char data[] = { START_BYTE, COMMAND_SET_COLOR,
                             (block & 0xFF),
                             reg1, // 0xff for *all* regions
                             reg2, // 0xff for *all* regions
                             reg3, // 0xff for *all* regions
                             red_green,
                             blue,
                             0 };
    return WriteDevice(alienfx, &data[0], sizeof data);
}	
示例#9
0
int Loop(libusb_device_handle *alienfx) // preceding commands are a loop 
{
    unsigned char data[] = { START_BYTE, COMMAND_LOOP_BLOCK_END };
    return WriteDevice(alienfx, &data[0], sizeof data);
}
示例#10
0
int SendAndExec(libusb_device_handle *alienfx)
{
    unsigned char data[] = { START_BYTE, COMMAND_TRANSMIT_EXECUTE };
    return WriteDevice(alienfx, &data[0], sizeof data);
}
示例#11
0
int SaveDone(libusb_device_handle *alienfx)
{ 
    unsigned char data[] = { START_BYTE, COMMAND_SAVE };
    return WriteDevice(alienfx, &data[0], sizeof data);
}
示例#12
0
int SaveNext(libusb_device_handle *alienfx, int block)
{
    unsigned char data[] = { START_BYTE, COMMAND_SAVE_NEXT,
                             (unsigned char)block };
    return WriteDevice(alienfx, &data[0], sizeof data);
}