📄 kprp.c
字号:
/*==============================================================================
* File Name: kprp.c
* 功能: 服务于Kitchen Printer/Receipt Printer
* 2006-9-6 16:27
*============================================================================*/
#include "ecrsys.h"
#include "ftype.h"
#include "data.h"
#include "sysdata.h"
extern volatile byte uart0_Sending ;
extern volatile byte uart1_Sending ;
extern volatile byte uart2_Sending ;
extern volatile byte uart3_Sending ;
extern volatile byte uart4_Sending ;
/*=============================================================================
* According to the KP/RP send data, check the ON/OFF
* status of it.
* 打印机端口,不存储任何数据于缓冲区。
* 在KP/RP送入数据给主机的时候,主机检查KP/RP所送的数据是否为XON/XOFF控制字
* 2006-9-6 17:25
*=============================================================================*/
void KPRP_XonOffChk(byte ch)
{
switch(ch)
{
case XON:
fl_kp_rp_busy = 0; /*printer not busy */
uc_kp_wait_timer = 0; /* no need spy the kp wait time */
kp_clr_cntr = 0; /*total 3 times*/
break;
case XOFF:
fl_kp_rp_busy = 1; /*kp is busy*/
uc_kp_wait_timer = KP_WAIT_TM;
break;
default:
break;
}
}
/*==================================================
* Send data to uart send register according to the
* KP/RP status
* If KP/RP during the busy status, then stop send
* Else Send to send buffer
* 2004-10-15 18:12
*=================================================*/
void KPRP_SendDataWithChk(byte port)
{
if (!fl_kp_rp_busy)
{
Uart_Send_Data(port);
}
else
{
switch(port)
{
case PORT0: /*Clear the during sending flag*/
uart0_Sending = 0;
break;
case PORT1:
uart0_Sending = 0;
break;
case PORT2:
uart0_Sending = 0;
break;
case PORT3:
uart0_Sending = 0;
break;
case PORT4:
uart0_Sending = 0;
break;
default:
break;
}
}
}
/******************************************************************************
* Check the KP/RP busy condition when the buffer is full.
* If still in XOFF mode, then waiting until the the timer out or xon comes.
*
* 检查KP/RP是否处于忙的状态,如果是,则报错并等待,如果报错次数超过3次,则清除发送
* 缓冲区中的数据
* 2006-9-6 17:30
*****************************************************************************/
/*此函数还需要重新改写才可以 2006-9-6 17:32 ZhengXiaoChun*/
CHR KPRP_BusyChk(void)
{
CHR i,j;
CHR port = 0;
CHR ch = OK;
WORD tmp = ERR_KP_TM_OUT;
CHR error_str[MAX_LCD_NUM];
if ( fl_kp_tm_out == 1 )
{
fl_kp_tm_out = 0;
error_str[0] = 'E';
for(i = 3; i > 0; i --)
{
j = tmp%10;
tmp /= 10;
error_str[i] = j + '0';
}
error_str[4] = '\0';
VFDDisplay(error_str, CLEARD, LEFT); /* Display the error information */
bellcnt = 0xFE;
while(GetKey_Ex() != KD_CLEAR); /*here wait the Clear key */
uc_kp_wait_timer = KP_WAIT_TM;
Clr_Dsp_Data(); /*clear the screen*/
RightDisp(0L, sysflag->sysdots); /*display 0.00*/
if ( ++ kp_clr_cntr == MAX_KP_WAIT_CNTR )
{ /*total 3 times can be used for clear*/
kp_clr_cntr = 0;
uc_kp_wait_timer = 0;
if ((port_sel1 == DEV_TYPE_KP) || (port_sel1 == DEV_TYPE_RP ))
port = PORT0;
else if ((port_sel2 == DEV_TYPE_KP) || (port_sel2 == DEV_TYPE_RP ))
port = PORT1; /*only one port can be linked to uart*/
ClrWrBuf(port); /*Clear the send buffer*/
ch = KD_KP_RP_BUSY;
}
}
return(ch);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -