Exemple #1
0
void Console_t::Put_Integer (long val, int width, int base)
{
	char nbuf [MAXNBUF], *p;
	int ch, neg = 0;

	if (val < 0) {
		neg = 1;
		val = -val;
	}

	/* Put a NUL-terminated ASCII number (base <= 36) in a buffer
	 * in reverse order; return an optional length and a pointer
	 * to the last character written in the buffer
	 * (i.e., the first character of the string). */
	p = nbuf;
	*p = 0;
	do {
		ch = val % base;
		val /= base;
		*++p = (ch > 9) ? (ch + 'a' - 10) : (ch + '0');
	} while (width > p - nbuf || val != 0);
	if (neg)
		*++p = '-';

	while (width-- > p - nbuf)
		Put_Char (' ');

	while (*p)
		Put_Char (*p--);
}
Exemple #2
0
void ANO_UART3::Put_String(unsigned char *Str)
{
	//判断Str指向的数据是否有效.
	while(*Str)
	{
	//是否是回车字符 如果是,则发送相应的回车 0x0d 0x0a
	if(*Str=='\r')Put_Char(0x0d);
		else if(*Str=='\n')Put_Char(0x0a);
			else Put_Char(*Str);
	//指针++ 指向下一个字节.
	Str++;
	}
}
Exemple #3
0
int main(int argc, char **argv)
{
    int fd, rc;
    char *filename;
    char buf[BUFSIZE];

    if (argc != 2) {
	Print("Usage: %s <filename>\n", argv[0]);
	Exit(1);
    }
    filename = argv[1];

    fd = Open(filename, O_READ);
    if (fd < 0)
	Print_Error("Could not open file", fd);

    for (;;) {
	int len = Read(fd, buf, BUFSIZE);
	if (len == 0)
	    break; /* EOF */
	else if (len < 0)
	    Print_Error("Read error", len);
	else {
	    int i;
	    for (i = 0; i < len; ++i)
		Put_Char(buf[i]);
	}
    }

    rc = Close(fd);
    if (rc < 0)
	Print_Error("Could not close file", rc);

    return 0;
}
Exemple #4
0
OS_INT8U Debug_Out_Public_Puck(OS_INT8U *Srcbuf,OS_INT16U Src_Len)
{
	INT8U i;
	
	for(i=0;i<Src_Len;i++)
		Put_Char(*(Srcbuf+i));

	return 1;
}