コード例 #1
0
static int getsync(void)
{
    int	c;

    PUTCHAR(0xaa);
    PUTCHAR(0x55);
    FLUSHOUT();
    Syslog('a', "getsync try to synchronize");

gs:
    if (tty_status) {
	WriteError("TCP: getsync failed %s", ttystat[tty_status]);
	return 1;
    }
    while ((c = GETCHAR(120)) != 0xaa)
	if (tty_status) {
	    WriteError("TCP: getsync failed: %s", ttystat[tty_status]);
	    return 1;
	}

    if ((c = GETCHAR(120)) != 0x55)
	goto gs;

    Syslog('a', "getsync done, tty_status %s", ttystat[tty_status]);
    return tty_status;
}
コード例 #2
0
ファイル: chap.c プロジェクト: AoLaD/rtems
/* ARGSUSED */
static void
ChapSendResponse(
    chap_state *cstate)
{
    u_char *outp;
    int outlen, md_len, name_len;

    md_len = cstate->resp_length;
    name_len = strlen(cstate->resp_name);
    outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);

    PUTCHAR(CHAP_RESPONSE, outp);	/* we are a response */
    PUTCHAR(cstate->resp_id, outp);	/* copy id from challenge packet */
    PUTSHORT(outlen, outp);		/* packet length */

    PUTCHAR(md_len, outp);		/* length of MD */
    BCOPY(cstate->response, outp, md_len);	/* copy MD to buffer */
    INCPTR(md_len, outp);

    BCOPY(cstate->resp_name, outp, name_len); /* append our name */

    /* send the packet */
    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);

    cstate->clientstate = CHAPCS_RESPONSE;
    TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime);
    ++cstate->resp_transmits;
}
コード例 #3
0
ファイル: pap.c プロジェクト: krzint/Szyfrator_NET
/*
 * upap_sauthreq - Send an Authenticate-Request.
 */
static void
upap_sauthreq(upap_state *u)
{
  u_char *outp;
  int outlen;

  outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) 
         + u->us_userlen + u->us_passwdlen;
  outp = outpacket_buf[u->us_unit];

  MAKEHEADER(outp, PPP_PAP);

  PUTCHAR(UPAP_AUTHREQ, outp);
  PUTCHAR(++u->us_id, outp);
  PUTSHORT(outlen, outp);
  PUTCHAR(u->us_userlen, outp);
  BCOPY(u->us_user, outp, u->us_userlen);
  INCPTR(u->us_userlen, outp);
  PUTCHAR(u->us_passwdlen, outp);
  BCOPY(u->us_passwd, outp, u->us_passwdlen);

  pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN);

  UPAPDEBUG((LOG_INFO, "pap_sauth: Sent id %d\n", u->us_id));

  TIMEOUT(upap_timeout, u, u->us_timeouttime);
  ++u->us_transmits;
  u->us_clientstate = UPAPCS_AUTHREQ;
}
コード例 #4
0
ファイル: upap.c プロジェクト: crvv/lwip
/*
 * upap_sresp - Send a response (ack or nak).
 */
static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, const char *msg, int msglen) {
    struct pbuf *p;
    u_char *outp;
    int outlen;

    outlen = UPAP_HEADERLEN + sizeof (u_char) + msglen;
    p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PPP_CTRL_PBUF_TYPE);
    if(NULL == p)
        return;
    if(p->tot_len != p->len) {
        pbuf_free(p);
        return;
    }

    outp = (u_char*)p->payload;
    MAKEHEADER(outp, PPP_PAP);

    PUTCHAR(code, outp);
    PUTCHAR(id, outp);
    PUTSHORT(outlen, outp);
    PUTCHAR(msglen, outp);
    MEMCPY(outp, msg, msglen);

    ppp_write(pcb, p);
}
コード例 #5
0
ファイル: chap.c プロジェクト: AoLaD/rtems
/*
 * ChapSendStatus - Send a status response (ack or nak).
 */
static void
ChapSendStatus(
    chap_state *cstate,
    int code)
{
    u_char *outp;
    int outlen, msglen;
    char msg[256];

    if (code == CHAP_SUCCESS)
	slprintf(msg, sizeof(msg), "Welcome to %s.", hostname);
    else
	slprintf(msg, sizeof(msg), "I don't like you.  Go 'way.");
    msglen = strlen(msg);

    outlen = CHAP_HEADERLEN + msglen;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);	/* paste in a header */

    PUTCHAR(code, outp);
    PUTCHAR(cstate->chal_id, outp);
    PUTSHORT(outlen, outp);
    BCOPY(msg, outp, msglen);
    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
}
コード例 #6
0
ファイル: upap.c プロジェクト: crvv/lwip
/*
 * upap_sauthreq - Send an Authenticate-Request.
 */
static void upap_sauthreq(ppp_pcb *pcb) {
    struct pbuf *p;
    u_char *outp;
    int outlen;

    outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) +
             pcb->upap.us_userlen + pcb->upap.us_passwdlen;
    p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PPP_CTRL_PBUF_TYPE);
    if(NULL == p)
        return;
    if(p->tot_len != p->len) {
        pbuf_free(p);
        return;
    }

    outp = (u_char*)p->payload;
    MAKEHEADER(outp, PPP_PAP);

    PUTCHAR(UPAP_AUTHREQ, outp);
    PUTCHAR(++pcb->upap.us_id, outp);
    PUTSHORT(outlen, outp);
    PUTCHAR(pcb->upap.us_userlen, outp);
    MEMCPY(outp, pcb->upap.us_user, pcb->upap.us_userlen);
    INCPTR(pcb->upap.us_userlen, outp);
    PUTCHAR(pcb->upap.us_passwdlen, outp);
    MEMCPY(outp, pcb->upap.us_passwd, pcb->upap.us_passwdlen);

    ppp_write(pcb, p);

    TIMEOUT(upap_timeout, pcb, pcb->settings.pap_timeout_time);
    ++pcb->upap.us_transmits;
    pcb->upap.us_clientstate = UPAPCS_AUTHREQ;
}
コード例 #7
0
/*---------------------------------------------------------------------------*/
static void
set_rime_addr(void)
{
    uint8_t *addr_long = NULL;
    uint16_t addr_short = 0;
    char i;

    __xdata unsigned char * macp = &X_IEEE_ADDR;

    PUTSTRING("Rime is 0x");
    PUTHEX(sizeof(rimeaddr_t));
    PUTSTRING(" bytes long\n");

    PUTSTRING("Reading MAC from Info Page\n");

    for(i = (RIMEADDR_SIZE - 1); i >= 0; --i) {
        rimeaddr_node_addr.u8[i] = *macp;
        macp++;
    }

    /* Now the address is stored MSB first */
#if STARTUP_VERBOSE
    PUTSTRING("Rime configured with address ");
    for(i = 0; i < RIMEADDR_SIZE - 1; i++) {
        PUTHEX(rimeaddr_node_addr.u8[i]);
        PUTCHAR(':');
    }
    PUTHEX(rimeaddr_node_addr.u8[i]);
    PUTCHAR('\n');
#endif

    cc2530_rf_set_addr(IEEE802154_PANID);
}
コード例 #8
0
ファイル: chap.c プロジェクト: AoLaD/rtems
/*
 * ChapSendChallenge - Send an Authenticate challenge.
 */
static void
ChapSendChallenge(
    chap_state *cstate)
{
    u_char *outp;
    int chal_len, name_len;
    int outlen;

    chal_len = cstate->chal_len;
    name_len = strlen(cstate->chal_name);
    outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);		/* paste in a CHAP header */

    PUTCHAR(CHAP_CHALLENGE, outp);
    PUTCHAR(cstate->chal_id, outp);
    PUTSHORT(outlen, outp);

    PUTCHAR(chal_len, outp);		/* put length of challenge */
    BCOPY(cstate->challenge, outp, chal_len);
    INCPTR(chal_len, outp);

    BCOPY(cstate->chal_name, outp, name_len);	/* append hostname */

    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);

    TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime);
    ++cstate->chal_transmits;
}
コード例 #9
0
ファイル: lib_printf.c プロジェクト: anbangr/bitvisor-dev
static int
do_conversion_string (const char *str, int f, int width, int precision,
		      int (*func)(int c, void *data), void *data)
{
	int len;
	int n = 0;
	int leftsp = 0, rightsp = 0;

	len = 0;
	while (!((f & HAS_PRECISION) && len >= precision) &&
	       str[len] != '\0')
		len++;
	if ((f & HAS_WIDTH) && width > len) {
		if (f & FLAG_LEFT_ADJUSTED)
			rightsp = width - len;
		else
			leftsp = width - len;
	}
	while (leftsp--)
		PUTCHAR (' ');
	while (len--)
		PUTCHAR (*str++);
	while (rightsp--)
		PUTCHAR (' ');
error:
	return n;
}
コード例 #10
0
int main()
{
	
	int t;
	t=readInt();
	while(t--)
	{
		int num=103993%33102;
		int den=33102;
		int n;
		n=readInt();
		
		PUTCHAR('3');
		if(n>0)
		{
			PUTCHAR('.');
			while(n)
			{
				num=num*10;
				PUTCHAR('0'+num/den);
				num=num%den;
				n--;
			}			
		}
		PUTCHAR('\n');
	}
	return 0;
}
コード例 #11
0
/*
 * fsm_sdata - Send some data.
 *
 * Used for all packets sent to our peer by this module.
 */
void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen) {
    ppp_pcb *pcb = f->pcb;
    struct pbuf *p;
    u_char *outp;
    int outlen;

    /* Adjust length to be smaller than MTU */
    if (datalen > pcb->peer_mru - HEADERLEN)
	datalen = pcb->peer_mru - HEADERLEN;
    outlen = datalen + HEADERLEN;

    p = pbuf_alloc(PBUF_RAW, (u16_t)(outlen + PPP_HDRLEN), PPP_CTRL_PBUF_TYPE);
    if(NULL == p)
        return;
    if(p->tot_len != p->len) {
        pbuf_free(p);
        return;
    }

    outp = (u_char*)p->payload;
    if (datalen) /* && data != outp + PPP_HDRLEN + HEADERLEN)  -- was only for fsm_sconfreq() */
	MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen);
    MAKEHEADER(outp, f->protocol);
    PUTCHAR(code, outp);
    PUTCHAR(id, outp);
    PUTSHORT(outlen, outp);
    ppp_write(pcb, p);
}
コード例 #12
0
//******************************************************************************
//	 			Generate PAP options ( username + password)
//******************************************************************************
void UPAPGenWapAuth(PAP_CnfgOptions_t *po, char * user,  char * password)
{
    char *us_user;              /* User */
    int us_userlen;             /* User length */
    char *us_passwd;            /* Password */
    int us_passwdlen;           /* Password length */
	
	int outlen;
	u_char *outp;

    /* Save the username and password we're given */
    us_user = user;
    us_userlen = strlen(user);
    us_passwd = password;
    us_passwdlen = strlen(password);

   outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) +
      us_userlen + us_passwdlen;
   outp = po->content;

   PUTCHAR(UPAP_AUTHREQ, outp);
   PUTCHAR(gChid, outp);
   PUTSHORT(outlen, outp);
   PUTCHAR(us_userlen, outp);
   memcpy(outp, us_user, us_userlen);
   INCPTR(us_userlen, outp);
   PUTCHAR(us_passwdlen, outp);
   memcpy(outp, us_passwd, us_passwdlen);

   po->len = outlen;
   po->flag = 1;
}
コード例 #13
0
void my_puts(char *s)
{
  while(*s)
    PUTCHAR(*s++);

  PUTCHAR('\n');
}
コード例 #14
0
void
SendKeys (int player, int c)
{
  PUTHEAD (SKEY);
  PUTCHAR (buffer + HEADSIZE, c);
  PUTCHAR (buffer + HEADSIZE + 1, player);
  csendreliable (buffer, HEADSIZE + 2);
}
コード例 #15
0
void
SendRotation (int player, int c)
{
  PUTHEAD (SROT);
  PUTCHAR (buffer + HEADSIZE, c);
  PUTCHAR (buffer + HEADSIZE + 1, player);
  csendreliable (buffer, HEADSIZE + 2);
}
コード例 #16
0
ファイル: Uart_gsm.c プロジェクト: saoirse-stewie/Project-
/*********************************************************************************************************
 * Function to print a modem response to the serial terminal
 * This function is used instead of printf because the PE Micro terminal only sends \r for a keyboard entry
 * The function adds a \n to every \r received
 ************************************************************************************************************/
void printf_response(char * ptr)
{
	while(*ptr != '\0')
	{
		PUTCHAR(*ptr);
		if(*ptr++ == '\r')
			PUTCHAR('\n');
	}
}
コード例 #17
0
/*
 * fsm_sconfreq - Send a Configure-Request.
 */
static void fsm_sconfreq(fsm *f, int retransmit) {
    ppp_pcb *pcb = f->pcb;
    struct pbuf *p;
    u_char *outp;
    int cilen;

    if( f->state != PPP_FSM_REQSENT && f->state != PPP_FSM_ACKRCVD && f->state != PPP_FSM_ACKSENT ){
	/* Not currently negotiating - reset options */
	if( f->callbacks->resetci )
	    (*f->callbacks->resetci)(f);
	f->nakloops = 0;
	f->rnakloops = 0;
    }

    if( !retransmit ){
	/* New request - reset retransmission counter, use new ID */
	f->retransmits = pcb->settings.fsm_max_conf_req_transmits;
	f->reqid = ++f->id;
    }

    f->seen_ack = 0;

    /*
     * Make up the request packet
     */
    if( f->callbacks->cilen && f->callbacks->addci ){
	cilen = (*f->callbacks->cilen)(f);
	if( cilen > pcb->peer_mru - HEADERLEN )
	    cilen = pcb->peer_mru - HEADERLEN;
    } else
	cilen = 0;

    p = pbuf_alloc(PBUF_RAW, (u16_t)(cilen + HEADERLEN + PPP_HDRLEN), PPP_CTRL_PBUF_TYPE);
    if(NULL == p)
        return;
    if(p->tot_len != p->len) {
        pbuf_free(p);
        return;
    }

    /* send the request to our peer */
    outp = (u_char*)p->payload;
    MAKEHEADER(outp, f->protocol);
    PUTCHAR(CONFREQ, outp);
    PUTCHAR(f->reqid, outp);
    PUTSHORT(cilen + HEADERLEN, outp);
    if (cilen != 0) {
	(*f->callbacks->addci)(f, outp, &cilen);
	LWIP_ASSERT("cilen == p->len - HEADERLEN - PPP_HDRLEN", cilen == p->len - HEADERLEN - PPP_HDRLEN);
    }

    ppp_write(pcb, p);

    /* start the retransmit timer */
    --f->retransmits;
    TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
}
コード例 #18
0
void
SendJoystick (int player, int x, int y, int buttons)
{
  PUTHEAD (SJOYSTICK);
  PUTSHORT (buffer + HEADSIZE, x);
  PUTSHORT (buffer + HEADSIZE + 2, y);
  PUTCHAR (buffer + HEADSIZE + 4, buttons);
  PUTCHAR (buffer + HEADSIZE + 5, player);
  csendreliable (buffer, HEADSIZE + 6);
}
コード例 #19
0
void
SendMouse (int player, int x, int y, int buttons)
{
  PUTHEAD (SMOUSE);
  PUTSHORT (buffer + HEADSIZE, x);
  PUTSHORT (buffer + HEADSIZE + 2, y);
  PUTCHAR (buffer + HEADSIZE + 4, buttons);
  PUTCHAR (buffer + HEADSIZE + 5, player);
  csendreliable (buffer, HEADSIZE + 6);
}
コード例 #20
0
void botrow(void)
{
    int	    i;

    pout(YELLOW, BLACK, (char *)" Ô");
    for (i = 0; i < LENSIGLINES; i++)
	PUTCHAR('Í');
    PUTCHAR('¾');
    Enter(1);
}
コード例 #21
0
ファイル: C2_Main.c プロジェクト: conorpp/C2.Flash
//-----------------------------------------------------------------------------
// GetString
//-----------------------------------------------------------------------------
//
// Return Value : Pointer to string containing buffer read from UART.
// Parameters   : <buf> to store string; maximum <n>umber of characters to
//                read; <n> must be 2 or greater.
//
// This function returns a string of maximum length <n>.
//-----------------------------------------------------------------------------
int GetString()
{
	char c;
	int len = 0;
	char *buffer = Command;
	int max_length = sizeof(Command) - 1;

	SetLedPeriod(900, 100);
	printf("READY\r\n> ");

	while(1)
	{
		c = GETCHAR();
		if (c != '\0')
		{
			if (c == '\b' || c == 0x7F)
			{
				if (len != 0)
				{
					PUTCHAR(c);
					--len;
					--buffer;
				}
			}
			else if (c == '\r' || c == '\n')
			{
				SetLedPeriod(0, 0);
				PUTCHAR('\n');
				if (max_length == 0)
				{
					printf("Result: FF COMMAND_TOO_LONG\n");
					buffer = Command;
				}
				*buffer = '\0';
				return len;
			}
			else if (len != max_length)
			{
				PUTCHAR(c);
				*buffer++ = c;
				len++;
			}
			else
			{
				max_length = 0;
				len = 0;
			}
		}
	}
}
コード例 #22
0
ファイル: uartprintf.c プロジェクト: anbae12/Code
void UARTCharPut(unsigned long ulBase, unsigned char ucData)
/*****************************************************************************
 * Function:    See header file.
 ****************************************************************************/
{
  PUTCHAR(ucData);
}
コード例 #23
0
ファイル: border-router.c プロジェクト: 1uk3/contiki
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
  static struct etimer et;

  PROCESS_BEGIN();
  PUTSTRING("Border Router started\n");
  prefix_set = 0;

  leds_on(LEDS_GREEN);

  /* Request prefix until it has been received */
  while(!prefix_set) {
    leds_on(LEDS_RED);
    PUTSTRING("Prefix request.\n");
    etimer_set(&et, CLOCK_SECOND);
    request_prefix();
    leds_off(LEDS_RED);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
  }
  /* We have created a new DODAG when we reach here */
  PUTSTRING("On Channel ");
  PUTDEC(cc2530_rf_channel_get());
  PUTCHAR('\n');

  print_local_addresses();

  leds_off(LEDS_GREEN);

  PROCESS_EXIT();

  PROCESS_END();
}
コード例 #24
0
ファイル: fsedit.c プロジェクト: bbs-io/mbse
void GetstrLC(char *sStr, int iMaxlen)
{
    unsigned char   ch = 0;
    int		    iPos = 0;

    strcpy(sStr, "");
    alarm_on();

    while (ch != 13) {

	ch = Readkey();

	if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
	    if (iPos > 0) {
		BackErase();
		sStr[--iPos] = '\0';
	    } else {
		Beep();
	    }
	}

	if ((ch > 31 && ch < 127) || traduce((char *)&ch)) {
	    if (iPos <= iMaxlen) {
		iPos++;
		snprintf(sStr + strlen(sStr), 5, "%c", ch);
		PUTCHAR(ch);
	    } else {
		Beep();
	    }
	}
    }

    Enter(1);
}
コード例 #25
0
ファイル: hsrp_fmt_plug.c プロジェクト: Allen-smith/ctf-tools
static int crypt_all(int *pcount, struct db_salt *salt)
{
	const int count = *pcount;
	int index = 0;
#ifdef _OPENMP
#pragma omp parallel for
	for (index = 0; index < count; index++)
#endif
	{
		uint32_t block[16] = { 0 };
		int len = saved_len[index];
		MD5_CTX ctx;
		MD5_Init(&ctx);
		// key + keyfill
		memcpy(block, saved_key[index], len);
		PUTCHAR(block, len, 0x80);
		block[14] = len << 3;
#if (ARCH_LITTLE_ENDIAN==0)
		block[14] = JOHNSWAP(block[14]);
#endif
		MD5_Update(&ctx, (unsigned char*)block, 64);
		// data
		MD5_Update(&ctx, cur_salt->salt, cur_salt->length);
		// key (again)
		MD5_Update(&ctx, saved_key[index], len);

		MD5_Final((unsigned char*)crypt_out[index], &ctx);
	}
	return count;
}
コード例 #26
0
ファイル: ccp.c プロジェクト: ajinkya93/OpenBSD
/** Create a Confugre-Request */
static void
ccp_addci(fsm *f, u_char *pktp, int *lpktp)
{
	u_char *pktp0;

	pktp0 = pktp;

	if (f->ppp->ccp.mppe_rej == 0) {
		PUTCHAR(CCP_MPPE, pktp);
		PUTCHAR(6, pktp);
		PUTLONG(f->ppp->ccp.mppe_o_bits, pktp);

		*lpktp = pktp - pktp0;
	} else
		*lpktp = 0;
}
コード例 #27
0
ファイル: lib_printf.c プロジェクト: anbangr/bitvisor-dev
static int
do_printf (const char *format, va_list ap, int (*func)(int c, void *data),
	   void *data)
{
	char c;
	int n, f;
	int width, precision;

	n = 0;
	while ((c = *format++) != '\0') {
		if (c == '%') {
			f = parse_format (&format, &width, &precision);
			if (f & LENGTH_INTMAX)
				f |= LENGTH_LONGLONG;
			else if (f & LENGTH_SIZE)
				f |= LENGTH_LONG;
			else if (f & LENGTH_PTRDIFF)
				f |= LENGTH_LONG;
			if (f == END_STRING) {
				break;
			} else if (f & CONVERSION_NONE) {
				PUTCHAR ('%');
			} else if (f & CONVERSION_INT) {
				long long intval;
				unsigned long long uintval;

				if (f & LENGTH_CHAR)
					intval = (long long)va_arg (ap, int);
				else if (f & LENGTH_SHORT)
					intval = (long long)va_arg (ap, int);
				else if (f & LENGTH_LONGLONG)
コード例 #28
0
/*!
 * @brief Main function
 */
int main (void)
{
    // RX buffers
    //! @param receiveBuff Buffer used to hold received data
    uint8_t receiveBuff;

    // Initialize standard SDK demo application pins
    hardware_init();

    // Call this function to initialize the console UART. This function
    // enables the use of STDIO functions (printf, scanf, etc.)
    dbg_uart_init();
    
    // Print the initial banner
    PRINTF("\r\nHello World!\n\n\r");

    while(1)
    {
        // Main routine that simply echoes received characters forever

        // First, get character
        receiveBuff = GETCHAR();

        // Now echo the received character
        PUTCHAR(receiveBuff);
    }
}
コード例 #29
0
ファイル: Uart_gsm.c プロジェクト: saoirse-stewie/Project-
/******************************************************************************************
 * Function to send a command to a GSM modem and to check response
 *
 * Passed Parameters:
 *  Pointer to command string
 *  Pointer to response buffer
 *  Size of response buffer
 *  Modem timeout time in seconds
 *
 * Return Value:
 *  0: OK response received from modem
 *  -1: ERROR: response received from MODEM
 *  -2: Modem timed out
 *******************************************************************************************/
int send_command(char * command_ptr, char * response_ptr, int size, int wait_time)
{
	volatile int time;
	char CR_count=0;
	int x, termination_char_received = 0, command_received=0;
	char c;
	char buff[20];
	char rx_count = 0;
	char *temp_ptr = response_ptr;
	PRINTF("HERE");

	for(x=0;x<size;x++) //clear response buffer
		*temp_ptr++ = 0;
	for(x=0;x<20;x++)
		buff[x] = 0;
	//send command to serial port
	while(*command_ptr != '\0')
	{
		PUTCHAR(*command_ptr++);
	}
	//wait for a command response or a timeout
	time = tick_count;
	x=0;
	while(!command_received &&(tick_count - time < wait_time))
	{
		c = buffer_get();
		if(c)   //buffer not empty
		{
			*response_ptr++ = c;
			rx_count++;
			if(!termination_char_received)
			{
				if(strstr(response_ptr - rx_count, "OK") || strstr(response_ptr - rx_count, "ERROR:"))
				{
					PRINTF("\nOK or ERROR received\n");
					termination_char_received = 1;
				}
			}
			else if(c == '\r')
			{
				command_received = 1;
				//printf("\nResponse Received:  \n");
			}
		}
	}
	if(command_received)
	{
		if(strstr(response_ptr - rx_count, "OK"))
			return SUCCESS;
		else if(strstr(response_ptr - rx_count, "ERROR:"))
			return ERROR;
	}
	else
	{
		PRINTF("\nTimeout on serial response\n");
		return FAIL;
	}

}
コード例 #30
0
ファイル: nmtslave.c プロジェクト: arkaheb258/infineon
void resetApplInd(void)
{
#ifdef NO_PRINTF_S
    PUTCHAR('X');
#else
    PRINTF("Application reset\n");
#endif
}