📄 dt_rspfmttr.c
字号:
// cid = rmmi_port_2_cid(port);
// ASSERT(cid != 0xff);
space = DT_MAX_DATA_INPUT_QUEUE_LENGTH - DT_PTR->uart_input_queue.length;
while (space > 0)
{
temp_read += actual_read ;/* only to print more detail trace information */
if (space > DT_MAX_UART_LENGTH)
{
actual_read = dt_uart_read_data (port, DT_MAX_UART_LENGTH);
if (actual_read < DT_MAX_UART_LENGTH)
break;
}
else
{
actual_read = dt_uart_read_data (port , space);
if (actual_read < space)
break;
}
space = DT_MAX_DATA_INPUT_QUEUE_LENGTH - DT_PTR->uart_input_queue.length;
}
space = DT_MAX_DATA_INPUT_QUEUE_LENGTH - DT_PTR->uart_input_queue.length;
temp_read += actual_read ;/* to print more detail trace information */
{
#ifdef UART_ENABLE
extern kal_uint8 send_Rxilm[2];
kal_trace (TRACE_INFO, INFO_DT_INPUT,
DT_PTR->uart_input_queue.length, space, temp_read,
send_Rxilm[port]);
#endif
}
if ((space == 0) ||
(DT_PTR->uart_input_queue.length == DT_MAX_DATA_INPUT_QUEUE_LENGTH))
{
kal_print("Warning: DT uart_input_queue Full!");
/* mtk00714: the data of +CMGS,+CMGW should not be too long. force to abort the short message */
#if 0
/* under construction !*/
/* under construction !*/
#ifdef __BTVCSR_HP__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
#ifdef UART_ENABLE
DT_UART_ClrRxBuffer(port, MOD_DT);
#endif
DT_PTR->uart_input_queue.length = 0;
DT_PTR->uart_input_queue.head = 0;
}
return;
}
/*****************************************************************************
* FUNCTION
* dt_uart_read_data
*
* DESCRIPTION
* This is dt_uart_read_data function of L4C module.
* get data from uart to rmmi input queue
*
* PARAMETERS
* none.
*
* RETURNS
* count number of bytes read from uart
*
* GLOBALS AFFECTED
* none.
*****************************************************************************/
kal_uint16 dt_uart_read_data (kal_uint8 port, kal_uint16 len)
{
kal_uint16 result;
kal_uint16 tail;
kal_uint16 i;
kal_uint8 buffer[DT_MAX_UART_LENGTH];
#ifndef UART_ENABLE
FILE *input;
#endif
kal_trace(TRACE_FUNC, FUNC_DT_UART_READ_DATA_ENTRY);
#ifdef UART_ENABLE
/* here's we really read the data from UART*/
result = DT_UART_GetBytes (port, (kal_uint8 *)buffer, len, NULL, MOD_DT);
#else
input = fopen ("c:\\mcu_in.log", "r");
fgets ((kal_char *)buffer, len, input);
result = strlen ((kal_char *)buffer);
fclose (input);
#endif
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#ifdef __BTVCSR_HP__ /* bluetooth : 2 physical uart */
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
//#ifdef __BTVCSR_HP__
// /* When Bluetooth is on,
// if (cid==1), the data is write to bluetooth port.
// if (cid==0), the data is write to PS UART PORT. */
// if (cid == 1)
// DT_PTR->BT_port = KAL_TRUE;
// else
// DT_PTR->BT_port = KAL_FALSE;
//#endif
for (i=0; i<result; i++)
{
if (buffer[i] == DT_PTR->s_reg.s5)
{
// Backspace :
// we have to check uart_input_queue length.
// if there's nothing in uart_input_queue (length == 0),
// then Backspace is ignored.
if (DT_PTR->uart_input_queue.length > 0)
{
DT_PTR->uart_input_queue.length--;
if ((DT_PTR->rsp_mode.echo_flag /*& (0x01 << cid)*/))
{ dt_write_to_uart(&buffer[i], 1, KAL_FALSE);}
}
}
#ifdef __BT_SUPPORT__
else
#else
else if((buffer[i]>=0x0a)&&(buffer[i]<0x80)) //for module: Maui_sw 9943
#endif
{
// Other charactors except Backspace
//generate echo
if ((DT_PTR->rsp_mode.echo_flag /*& (0x01 << cid)*/))
{ dt_write_to_uart(&buffer[i], 1, KAL_FALSE);}
//put the char in uart_input_queue
tail = (DT_PTR->uart_input_queue.head +
DT_PTR->uart_input_queue.length) % DT_MAX_DATA_INPUT_QUEUE_LENGTH ;
DT_PTR->uart_input_queue.data[tail] = buffer[i];
DT_PTR->uart_input_queue.length++;
}
}
//#ifdef __BTVCSR_HP__
// if (DT_PTR->BT_port == KAL_TRUE)
// DT_PTR->BT_port = KAL_FALSE; //clear the Bluetooth information
/* begin: only for debugging */
//uart 3 : we copy BT chip command to uart 1 for debugging
// #ifdef __RMMI_BT_DEBUG__
// if ((cid == 1) && (DT_PTR->BT_as_serial_port == KAL_FALSE))
// {
// for (i=0; i<result; i++)
// {
// rmmi_write_to_uart(&buffer[i], 1, KAL_FALSE);
// }
// }
// #endif
/* end : only for debugging */
//#endif
return result;
}
kal_uint16 dt_fast_string_print (
kal_uint8 *buff_ptr,
kal_uint8 *fmt,
void *arg_list[],
kal_uint8 nos_arg
)
{
kal_int32 digit = 0;
// kal_int16 digit = 0;
kal_uint8 character;
kal_uint8 dec_val[15];
/* array to store decimal number in the form of string */
//kal_uint8 *str_ptr;
kal_uint8 index = 0;
kal_uint16 buffer_length = 0;
kal_uint8 arg_indx = 0;
kal_bool int_str_ptr_flag = KAL_FALSE;
kal_bool negative_flag = KAL_FALSE;
kal_trace(TRACE_FUNC, FUNC_DT_FAST_STRING_PRINT_ENTRY);
while( *fmt )
{
/* store into the buffer if we find any non '%' character */
if (*fmt != DT_CHAR_PERCENT || nos_arg == 0)
{
/*increment the buffer index and input string index by one*/
*buff_ptr++ = *fmt++;
buffer_length++;
continue;
}
/* If we find '%' character then we require to see for
* corresponding conversion specifier like d (for integer)
* c (for character )
* s (for string )
* this is analyzed using switch - case statement */
switch ( *++fmt )
{
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/* String print a kal_uint16 type variable */
case dt_char_u :
{
/* Get the integer value from the string format */
digit = *((kal_uint16 *)arg_list[arg_indx++]);
int_str_ptr_flag = KAL_TRUE;
break;
}
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/* String print a kal_uint8 type variable */
case dt_char_d :
{
/* Get the integer value from the string format */
digit = *((kal_uint8 *)arg_list[arg_indx++]);
int_str_ptr_flag = KAL_TRUE;
break;
}
case dt_char_c :
{
/* get the character from the given string format */
character = *((kal_uint8 *)arg_list[arg_indx++]);
/* update the buffer */
*buff_ptr++ = character;
buffer_length++;
break;
}
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
default :
{
/* if no conversion specifier is found after '%' character
* store that character as it is in to the buffer */
*buff_ptr++ = *fmt;
buffer_length++;
break;
}
} /* end switch */
if( int_str_ptr_flag == KAL_TRUE )
{
if (digit < 0)
{
negative_flag = KAL_TRUE;
digit = digit *( -1);
}
dt_int_to_ascii_converter ( digit, dec_val );
/*convert the integer into string*/
index = 0;
/* store converted decimal value into the buffer */
if ( negative_flag == KAL_TRUE )
{
*buff_ptr++ = DT_CHAR_MINUS;
buffer_length++;
}
while(dec_val[index] != DT_END_OF_STRING_CHAR)
{
*buff_ptr++ = dec_val[index++];
buffer_length++;
}
int_str_ptr_flag = KAL_FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -