📄 pc_comm.c
字号:
if(Verify_CS(Data_Area,Rpt_Data_Len,Check_Sum) == NOTOK) /* Verify the check sum is right or not */
{
Send_Error_Info(CS_ERR); /* The check sum is error */
continue;
}
break;
}
else
{
/***********************************/
for(i = 0; i < Data_Len; i ++) /* The Data_Len can be 0 */
{
for(j = 0; j < LOOPCNT; )
{
if(Chk_KeyPrs_LockChg(1) == NOTOK)
return (NOTOK);
if(Uart_ReadByte(COMM_PORT,Data_Area+i) == OK)
break;
j ++;
}
if(j == LOOPCNT)
{
flag = 1;
Send_Error_Info(COMM_TIME_OVER);
break;
}
}
if(flag == 1)
continue;
/***********************************/
for(j = 0; j < LOOPCNT; )
{
if(Chk_KeyPrs_LockChg(1) == NOTOK)
return (NOTOK);
if(Uart_ReadByte(COMM_PORT,&Check_Sum) == OK) /* Get the data's check sum */
break;
j ++;
}
if(j == LOOPCNT)
{
Send_Error_Info(COMM_TIME_OVER);
continue;
}
if(Verify_CS(Data_Area,Data_Len,Check_Sum) == NOTOK) /* Verify the check sum is right or not */
{
Send_Error_Info(CS_ERR); /* The check sum is error */
continue;
}
break;
}
}
return (OK);
}
/*-----------------------------------------------------------------------*
Send the start head to the PC.
Only 6 0xFE is ok.
*-----------------------------------------------------------------------*/
void Write_Head(void)
{
byte i;
for(i = 0; i < 6; i ++)
Uart_WriteByte(COMM_PORT,0xFE);
}
/*-----------------------------------------------------------------------*
Send the error information to the PC.
*-----------------------------------------------------------------------*/
void Send_Error_Info(byte Error_Type)
{
byte i;
byte sum;
for(i = 0; i < 6; i ++)
Send_Buff[i] = 0xFE;
Send_Buff[6] = ECHO_ER;
Send_Buff[7] = 2;
Send_Buff[8] = Error_Type/10 + '0';
Send_Buff[9] = Error_Type%10 + '0';
sum = (Error_Type/10 + '0') + (Error_Type%10 + '0'); /* Calculate the check sum */
Send_Buff[10] = sum;
Wr_Str_Uart(COMM_PORT,Send_Buff,11); /* Send the information to the PC */
}
/*-------------------------------------------------------------------------*
Send the succeed information to the PC machine.
*-------------------------------------------------------------------------*/
void Send_Succeed_Info(void)
{
Write_Head(); /* Write the head information */
Uart_WriteByte(COMM_PORT,ECHO_OK);
Uart_WriteByte(COMM_PORT,0x02);
Uart_WriteByte(COMM_PORT,0x00);
Uart_WriteByte(COMM_PORT,0x00);
Uart_WriteByte(COMM_PORT,0x00);
}
/*-----------------------------------------------------------------------*
Calculate the check sum.
*-----------------------------------------------------------------------*/
void CalCS(byte *src_str, word length, byte *check_sum)
{
word i;
*check_sum = 0;
for(i = 0; i < length; i ++)
{
*check_sum += src_str[i];
}
}
/*-----------------------------------------------------------------------*
Read the data sended from the PC machine.
*-----------------------------------------------------------------------*/
void Read_Data_PC(void)
{
VFDDisplay(Disp_Comm_Rec,LEFT,NOTCLEARD);
// comm_disp_port();
switch(Comd_Type)
{
case PLU_DWN: /* PLU parameter down-load */
Do_PLU_Dwn();
break;
#ifdef SCANNER /* Support the scanner function */
case PLU_IDX_DWN: /* PLU index table down-load */
#ifdef VER_RSNT /* Support the restaurant function */
if(Rsnt_ChkSale() == NOTOK)
{
PC_Comm_Exit_Send();
errorType(ERR_SALE_NO_END);
Make_Virtual_Key(KD_CLEAR); /* Exit the communication */
return;
}
#endif /* End VER_RSNT */
Do_PLU_Idx_Dwn();
break;
#endif /* End SCANNER */
case SYS_PARA_DWN: /* System parameter down-load */
Do_Sys_Para_Dwn();
break;
case CLERK_DWN: /* Clerk parameter down-load */
Do_Clerk_Dwn();
break;
case TTL_DESC_DWN: /* Total description down-load */
Do_Ttl_Desc_Dwn();
break;
case RFND_DWN: /* Refund parameter down-load */
Do_Rfnd_Dwn();
break;
// case WLCM_BOTM_MSG_DWN: /* Welcome & Trailer message down-load */
// Do_Wlcm_Botm_Msg_Dwn();
// break;
case DEPT_DWN: /* Department parameter down-load */
Do_Dept_Dwn();
break;
case PER_DWN: /* Percent parameter down-load */
Do_Per_Dwn();
break;
case RAM_LOGO_DWN: /* Ram Logo down-load */
Do_Ram_Logo_Dwn();
break;
case SNGL_PLU_DWN: /* Single PLU down-load */
Do_Sngl_PLU_Dwn();
break;
#ifdef STOCK /* Support the stock function */
case PLU_STOCK_DWN: /* PLU stock down-load */
Do_PLU_Stock_Dwn();
break;
case SNGL_PLU_STOCK_DWN: /* Single PLU stock down-load */
Do_Sngl_PLU_Stock_Dwn();
break;
#endif /* End STOCK */
case KEY_LAYOUT_DWN:
Do_Key_Layout_Dwn(); /* Keyboard layout down-load */
break;
case KB_POS_LAYOUT_DWN:
Do_KB_POS_Layout_Dwn(); // POS Keyboard layout down-load
break;
case WLCM_MSG_DWN: /* Welcome message down-load */
Do_Wlcm_Msg_Dwn();
break;
case BOTM_MSG_DWN: /* Trailer message down-load */
Do_Botm_Msg_Dwn();
break;
case VAT_DWN:
Do_VAT_Dwn();
break;
case TAX_DWN:
Do_Tax_Dwn();
break;
#ifdef PC_TEST
case PST_DWN:
Send_Succeed_Info();
break;
#endif
case PCASH_DWN:
Do_PCASH_Dwn();
break;
#ifdef FCE_FUNC /* Support the FCE function */
case FCE_DWN:
Do_FCE_Dwn();
break;
#endif /* End FCE_FUNC */
#ifdef VER_RSNT /* Support the restaurant function */
case TABLE_DWN:
Do_Table_Dwn();
break;
case WAITER_DWN:
Do_Waiter_Dwn();
break;
#endif /* End VER_RSNT */
case REGI_DESC_DWN: /* Register descriptor down-load */
Do_Regi_Desc_Dwn();
break;
// case KP_RP_FLAG_DWN:
// Do_KP_RP_Flag_Dwn();
// break;
case ECHO_STATUS:
case HAND_SHAKE:
/* Remain */
break;
#ifdef REST_PLU_FUNC
case PLUTAB_DWN:
Do_PLU_relation_tabl_Dwn();
break;
#endif
#ifdef ELEC_SCALE
case SCALEPLU_PARA_DWN:
Do_Scale_PLU_Para_Dwn();
break;
case SCALEPLU_DATA_DWN:
Do_Scale_PLU_Data_Dwn();
break;
#endif
default: /* The nonexistent command code. */
Send_Error_Info(NON_EXIST_CMD);
break;
}
}
/*-----------------------------------------------------------------------*
Send the data to the PC machine.
*-----------------------------------------------------------------------*/
void Send_Data_PC(void)
{
VFDDisplay(Disp_Comm_Send,NOTCLEARD,LEFT);
// comm_disp_port();
switch(Comd_Type)
{
case PLU_UP: /* PLU parameter up -load */
Do_PLU_Up();
break;
#ifdef SCANNER /* Support the scanner function */
case PLU_IDX_UP: /* PLU index table up -load */
Do_PLU_Idx_Up();
break;
#endif /* End SCANNER */
case SYS_PARA_UP: /* System parameter up -load */
Do_Sys_Para_Up();
break;
case CLERK_UP: /* Clerk parameter up -load */
Do_Clerk_Up();
break;
case TTL_DESC_UP: /* Total description up -load */
Do_Ttl_Desc_Up();
break;
case RFND_UP: /* Refund parameter up-load */
Do_Rfnd_Up();
break;
// case WLCM_BOTM_MSG_UP: /* Welcome & Trailer message up -load */
// Do_Wlcm_Botm_Msg_Up();
// break;
case DEPT_UP: /* Department parameter up -load */
Do_Dept_Up();
break;
case PER_UP: /* Percent parameter up -load */
Do_Per_Up();
break;
case SNGL_PLU_UP: /* Single PLU up-load */
Do_Sngl_PLU_Up();
break;
#ifdef STOCK /* Support the stock function */
case PLU_STOCK_UP:
Do_PLU_Stock_Up();
break;
case SNGL_PLU_STOCK_UP: /* Single PLU stock up-load */
Do_Sngl_PLU_Stock_Up();
break;
#endif /* End STOCK */
case KEY_LAYOUT_UP:
Do_Key_Layout_Up(); /* Keyboard layout up-load */
break;
case KB_POS_LAYOUT_UP:
Do_KB_POS_Layout_Up(); // POS Keyboard layout up-load
break;
case WLCM_MSG_UP:
Do_Wlcm_Msg_Up(); /* Welcome message up-load */
break;
case BOTM_MSG_UP:
Do_Botm_Msg_Up(); /* Bottom message up-load */
break;
case VAT_UP:
Do_VAT_Up();
break;
case TAX_UP:
Do_Tax_Up();
break;
#ifdef PC_TEST
case PST_UP:
break;
#endif
case PCASH_UP:
Do_PCASH_Up();
break;
#ifdef FCE_FUNC /* Support the FCE function */
case FCE_UP:
Do_FCE_Up();
break;
#endif /* End FCE_FUNC */
#ifdef VER_RSNT /* Support the restaurant function */
case TABLE_UP:
Do_Table_Up();
break;
case WAITER_UP:
Do_Waiter_Up();
break;
#endif /* End VER_RSNT */
case REGI_DESC_UP: /* Register descriptor up-load */
Do_Regi_Desc_Up();
break;
// case KP_RP_FLAG_UP:
// Do_KP_RP_Flag_Up();
// break;
#ifdef ELEC_JRNL
case SALE_JRNL_UP: /* Sale journal up-load */
Do_Sale_Jrnl_Up();
break;
case DC_JRNL_UP: /* Discount journal up-load */
Do_Dc_Jrnl_Up();
break;
case RM_JRNL_UP: /* Return Merchandise journal up-load */
Do_Rm_Jrnl_Up();
break;
case SALE_JRNL_UP2: /* Sale journal up-load (Second way) */
Do_Sale_Jrnl_Up2();
break;
case DC_JRNL_UP2: /* Discount journal up-load (Second way) */
Do_Dc_Jrnl_Up2();
break;
case RM_JRNL_UP2: /* Return Merchandise journal up-load (Second way) */
Do_Rm_Jrnl_Up2();
break;
#endif
case DAILY_RPT_UP_X: /* Daily report up-load (X) */
case DAILY_RPT_UP_Z: /* Daily report up-load (Z) */
case PTD_RPT_UP_X: /* Period report up-load (X) */
case PTD_RPT_UP_Z: /* Period report up-load (Z) */
Do_Full_Rpt_Up(); /* Full report up-load */
break;
case DAILY_PLU_UP_X: /* Daily PLU report up-load (X) */
case DAILY_PLU_UP_Z: /* Daily PLU report up-load (Z) */
case PTD_PLU_UP_X: /* Period PLU report up-load (X) */
case PTD_PLU_UP_Z: /* Period PLU report up-load (Z) */
Do_PLU_Rpt_Up();
break;
case DAILY_CLERK_UP_X: /* Daily clerk report up-load (X) */
case DAILY_CLERK_UP_Z: /* Daily clerk report up-load (Z) */
case PTD_CLERK_UP_X: /* Period clerk report up-load (X) */
case PTD_CLERK_UP_Z: /* Period clerk report up-load (Z) */
Do_Clerk_Rpt_Up();
break;
#ifdef VER_RSNT /* Support the restaurant function */
case TOT_TABLE_UP_X: /* Total table report up-load (X) */
case TOT_TABLE_UP_Z: /* Total table report up-load (Z) */
Do_Table_Rpt_Up();
break;
#endif /* End VER_RSNT */
case HOURLY_RPT_UP_X: /* Hourly sales report up-load (X) */
case HOURLY_RPT_UP_Z: /* Hourly sales report up-load (Z) */
Do_Hourly_Rpt_Up();
break;
#ifdef VER_RSNT /* Support the restaurant function */
case ACITVE_TABLE_UP_X:
Do_Active_Table_Up();
break;
case WAITER_RPT_UP_X:
case WAITER_RPT_UP_Z:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -