コード例 #1
0
ファイル: CDC.c プロジェクト: emcute0319/ir-usb-kbd
static int CDC_Device_getchar(FILE* Stream)
{
	if (!(CDC_Device_BytesReceived((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))))
	  return _FDEV_EOF;

	return CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));
}
コード例 #2
0
ファイル: CDC.c プロジェクト: emcute0319/ir-usb-kbd
static int CDC_Device_getchar_Blocking(FILE* Stream)
{
	while (!(CDC_Device_BytesReceived((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))))
	{
		if (USB_DeviceState == DEVICE_STATE_Unattached)
		  return _FDEV_EOF;
	
		CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));
		USB_USBTask();
	}

	return CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));
}
コード例 #3
0
static int AOA_Host_getchar_Blocking(FILE* Stream)
{
	int16_t ReceivedByte;

	while ((ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream))) < 0)
	{
		if (USB_HostState == HOST_STATE_Unattached)
		  return _FDEV_EOF;

		AOA_Host_USBTask((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));
		USB_USBTask();
	}

	return ReceivedByte;
}
コード例 #4
0
ファイル: PrinterClassDevice.c プロジェクト: 40000ft/lufa
static int PRNT_Device_getchar_Blocking(FILE* Stream)
{
	int16_t ReceivedByte;

	while ((ReceivedByte = PRNT_Device_ReceiveByte((USB_ClassInfo_PRNT_Device_t*)fdev_get_udata(Stream))) < 0)
	{
		if (USB_DeviceState == DEVICE_STATE_Unattached)
		  return _FDEV_EOF;

		PRNT_Device_USBTask((USB_ClassInfo_PRNT_Device_t*)fdev_get_udata(Stream));
		USB_USBTask();
	}

	return ReceivedByte;
}
コード例 #5
0
ファイル: Serial_XMEGA.c プロジェクト: 0xdec/tmk_keyboard
int Serial_getchar_Blocking(FILE *Stream)
{
	USART_t* USART = fdev_get_udata(Stream);

	while (!(Serial_IsCharReceived(USART)));
	return Serial_ReceiveByte(USART);
}
コード例 #6
0
ファイル: Serial_XMEGA.c プロジェクト: 0xdec/tmk_keyboard
int Serial_putchar(char DataByte,
                   FILE *Stream)
{
	USART_t* USART = fdev_get_udata(Stream);

	Serial_SendByte(USART, DataByte);
	return 0;
}
コード例 #7
0
ファイル: LufaUtil.c プロジェクト: hokim72/ATmega32U4
int Device_getchar(FILE* Stream)
{
	int16_t ReceivedByte = Device_ReceiveByte((USB_EPInfo_Device_t*)fdev_get_udata(Stream));

	if (ReceivedByte < 0)
		return _FDEV_EOF;

	return ReceivedByte;
}
コード例 #8
0
ファイル: CDC.c プロジェクト: cloud-hot/Jennisense
static int CDC_Device_getchar(FILE* Stream)
{
	int16_t ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));

	if (ReceivedByte < 0)
	  return _FDEV_EOF;

	return ReceivedByte;
}
コード例 #9
0
ファイル: Serial_XMEGA.c プロジェクト: 0xdec/tmk_keyboard
int Serial_getchar(FILE *Stream)
{
	USART_t* USART = fdev_get_udata(Stream);

	if (!(Serial_IsCharReceived(USART)))
	  return _FDEV_EOF;

	return Serial_ReceiveByte(USART);
}
コード例 #10
0
static int AOA_Host_getchar(FILE* Stream)
{
	int16_t ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));

	if (ReceivedByte < 0)
	  return _FDEV_EOF;

	return ReceivedByte;
}
コード例 #11
0
ファイル: CDCClassDevice.c プロジェクト: ilikecake/AVR-Common
static int CDC_Device_putchar(char c,
                              FILE* Stream)
{
	if(c == 0x0A)
	{
		CDC_Device_putchar(0x0D, Stream);
	}
	return CDC_Device_SendByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;
}
static int CDC_Device_getchar_Blocking(FILE* Stream)
{
	int16_t ReceivedByte = 0;

	while ((ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))) < 0)
	{
		if (USB_DeviceState != DEVICE_STATE_Unattached)
		{
			CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));
			USB_USBTask();
		}
		else
		{
			ReceivedByte = (int16_t)_FDEV_EOF;
		}
	}

	return ReceivedByte;
}
コード例 #13
0
int
BetterStream::_getchar(FILE *stream)
{
    BetterStream      *bs;

    bs = (BetterStream *)fdev_get_udata(stream);

    // We return -1 if there is nothing to read, which the library interprets
    // as an error, which our clients will need to deal with.
    return(bs->read());
}
コード例 #14
0
int
BetterStream::_putchar(char c, FILE *stream)
{
    BetterStream      *bs;

    bs = (BetterStream *)fdev_get_udata(stream);
    if ('\n' == c)
        bs->write('\r');        // ASCII translation on the cheap
    bs->write(c);
    return(0);
}
コード例 #15
0
int buffer_stream_getchar(FILE *f)
{
buffer_stream_t *pbs;
int c;
    pbs = fdev_get_udata(f);
    if( pbs->incb != NULL)
    {
        pbs->incb(pbs->pbufin);
    }
    c = buffer_get_char(pbs->pbufin);
    return c;
}
コード例 #16
0
int buffer_stream_putchar(char c, FILE *f)
{
buffer_stream_t *pbs;

    pbs = fdev_get_udata(f);
    buffer_append_char(pbs->pbufout, c);
    if( pbs->outcb != NULL)
    {
        pbs->outcb(pbs->pbufout);
    }
    return EOF;
}
コード例 #17
0
ファイル: HTTPClient.cpp プロジェクト: hex705/avviso
int
HTTPClient::clientWrite(char byte, FILE* stream)
{
  if (stream == NULL)
    {
      return EOF;
    }
  http_stream_udata* udata = (http_stream_udata*) fdev_get_udata(stream);
  HTTPClient* client = udata->client;
  if (client->connected() == 0)
    {
      closeStream(stream);
      return EOF;
    }
  if (udata->encode == 0)
    {
      client->write(byte);
      if (client->debugCommunication)
        {
          Serial.print(byte);
        }
    }
  else
    {
      if (URI_ALLOWED(byte) || ((URI_RESERVED(byte) && (udata->encode
          & URI_ENCODE_RESERVED) == 0)))
        {
          client->write(byte);
          if (client->debugCommunication)
            {
              Serial.print(byte);
            }
        }
      else
        {
          char encoded[4] =
            { 0, 0, 0 };
          sprintf(encoded, "%%%2x", byte);
          // Write only the first three bytes, not the trailing null
          for (char i = 0; i < 3; i++)
            {
              client->write(encoded[i]);
              if (client->debugCommunication)
                {
                  Serial.print(encoded[i]);
                }
            }
        }
    }
  return 0;
}
コード例 #18
0
ファイル: HTTPClient.cpp プロジェクト: hex705/avviso
void
HTTPClient::closeStream(FILE* stream)
{
  if (stream != NULL)
    {
      http_stream_udata* udata = (http_stream_udata*) fdev_get_udata(stream);
      if (udata->client->connected())
        {
          udata->client->stop();
        }
      free(udata);
      fclose(stream);
    }
}
コード例 #19
0
ファイル: ttyopen.c プロジェクト: 9MMMinor/avrXinu-V7
int
stdGet(FILE * stream)
{
	STATWORD ps;    
	int	ch;
	struct	tty   *iptr;
	
	disable(ps);
	iptr = (struct tty *)fdev_get_udata(stream);
	wait(iptr->isem);		/* wait	for a character	in buff	*/
	ch = 0xff & iptr->ibuff[iptr->itail++];
	--iptr->icnt;
	if (iptr->itail	>= IBUFLEN)
		iptr->itail = 0;
	if (iptr->ieof && (iptr->ieofc == ch) )
		ch = EOF;
	restore(ps);
	return(ch);
}
コード例 #20
0
ファイル: ttyopen.c プロジェクト: 9MMMinor/avrXinu-V7
/* prototype for a pseudo driver BUT ONLY FOR tty */
int
stdPut(char ch, FILE * stream)
{
	STATWORD ps;    
	struct tty *iptr;
	
	iptr = (struct tty *)fdev_get_udata(stream);
	if ( ch==NEWLINE && iptr->ocrlf )
		stdPut(RETURN, stream);
	disable(ps);
	wait(iptr->osem);		/* wait	for space in queue	*/
	iptr->obuff[iptr->ohead++] = ch;
	++iptr->ocnt;
	if (iptr->ohead	>= OBUFLEN)
		iptr->ohead = 0;
	*USART[iptr->unit].UCSRB |= (1<<UDRIE0);			/*ttyostart(iptr);*/
	restore(ps);
	return(OK);	
}
コード例 #21
0
ファイル: HTTPClient.cpp プロジェクト: hex705/avviso
void
HTTPClient::setEncoding(FILE* stream, char encode, char encodeReserved)
{
  http_stream_udata* udata = (http_stream_udata*) fdev_get_udata(stream);
  if (encode == 0)
    {
      udata->encode = 0;
    }
  else
    {
      if (encodeReserved)
        {
          udata->encode = URI_ENCODE | URI_ENCODE_RESERVED;
        }
      else
        {
          udata->encode = URI_ENCODE;
        }
    }
}
コード例 #22
0
ファイル: Print.cpp プロジェクト: MCUdude/MiniCore
// Custom implementation of printf borrowed from the teensy core files
static int16_t printf_putchar(char c, FILE *fp)
{
	((class Print *)(fdev_get_udata(fp)))->write((uint8_t)c);
	return 0;
}
コード例 #23
0
ファイル: uart.c プロジェクト: robotter/avarix
int uart_dev_send(char c, FILE *fp)
{
  return uart_send(fdev_get_udata(fp), c);
}
コード例 #24
0
ファイル: HTTPClient.cpp プロジェクト: hex705/avviso
int
HTTPClient::clientRead(FILE* stream)
{
  if (stream == NULL)
    {
      return EOF;
    }
  http_stream_udata* udata = (http_stream_udata*) fdev_get_udata(stream);
  HTTPClient* client = udata->client;
  if (!client->connected())
    {
      return EOF;
    }
  //block until we got a byte
  while (client->available() == 0)
    {
      if (client->connected() == 0)
        {
          return EOF;
        }
    };
  int result = client->read();
  if (result == EOF)
    {
      return EOF;
    }
  if (client->debugCommunication)
    {
      Serial.print((byte) result);
    }
  //as long as we do not read encoded or it is no % everything is ok
  if (udata->encode == 0 || result != '%')
    {
      return result;
    }
  else
    {
      //block until we got the needed bytes
      while (client->available() >= 2)
        {
          if (client->connected() == 0)
            {
              return EOF;
            }
        };
      char return_value = 0;
      for (char i = 0; i < 2; i++)
        {
          result = client->read();
          if (result == EOF)
            {
              return EOF;
            }
          else if (result >= 'A' && result <= 'Z')
            {
              return_value += (1 - i) * 16 * (result - 'A');
            }
          else if (result >= 'a' && result <= 'z')
            {
              return_value += (1 - i) * 16 * (result - 'a');
            }
          else if (result >= '0' && result <= '9')
            {
              return_value += (1 - i) * 16 * (result - '0');
            }
        }
      return return_value;
    }
}
コード例 #25
0
static int AOA_Host_putchar(char c,
                            FILE* Stream)
{
	return AOA_Host_SendByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;
}
コード例 #26
0
ファイル: uart.c プロジェクト: robotter/avarix
int uart_dev_recv(FILE *fp)
{
  return uart_recv(fdev_get_udata(fp));
}
コード例 #27
0
ファイル: multiwii.c プロジェクト: AdamRLukaitis/martink
static int _serial_fd_getc(FILE *stream){
	serial_dev_t dev = fdev_get_udata(stream); 
	return serial_getc(dev) & 0xff; 
}
コード例 #28
0
ファイル: multiwii.c プロジェクト: AdamRLukaitis/martink
static void _serial_fd_putc(int c, FILE *stream){
	serial_dev_t dev = fdev_get_udata(stream); 
	serial_putc(dev, c); 
}
コード例 #29
0
ファイル: LufaUtil.c プロジェクト: hokim72/ATmega32U4
int Device_putchar(char c, FILE* Stream)
{
	return Device_SendByte((USB_EPInfo_Device_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;
}
コード例 #30
0
ファイル: PrinterClassDevice.c プロジェクト: 40000ft/lufa
static int PRNT_Device_putchar(char c,
                               FILE* Stream)
{
	return PRNT_Device_SendByte((USB_ClassInfo_PRNT_Device_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;
}