📄 ez320.c
字号:
#include <stdio.h>
#include <string.h>
#include <process.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include "NULLINCL.H"
#include "ACKINCL.H"
#include "485INCL.H"
#include "DEFINES.H"
// Variables
static char *version="V1.0";
static int baudtbl[]={110,150,300,600,1200,2400,4800,9600,19200};
static char *paritytbl[]={"None","Odd","Even"};
static char *prototbl[]={"NULL","ACK/NAK","MULTI-POINT"};
static char address[32];
static int port,baud,databit,stopbit,parity,protocol;
static int addr_count=0;
static COM_CONFIG com_tbl;
// Function Prototypes
static void aChangeProtocol(void);
static void aSelectAddress(void);
static void aWarmStart(void);
static void aColdStart(void);
static void aSyncTime(void);
static void get_current_time(char *str);
static void aPoll(void);
static int getchx(void);
static void ret_msg(int ret);
// Main Program
void main(void)
{
int ch,i;
do{
printf("\n\tCOM(1/2/3/4)?:");
ch=getch();
printf("%c\n",ch);
}while( ch<'1' || ch>'4');
port=ch-'0';
do{
printf("\n\tBAUD(0:110,1:150,2:300,3:600,4:1200,5:2400,6:4800,7:9600,8:19200)?");
ch=getch();
printf("%c\n",ch);
}while((ch>'8') || (ch<'0'));
baud=ch-'0';
com_tbl.baud=(char)ch;
do{
printf("\n\tDATA BIT(7/8)?:");
ch=getch();
printf("%c\n",ch);
}while((ch > '8') || (ch < '7'));
databit=ch-'7';
com_tbl.databit=(char)ch;
do{
printf("\n\tSTOP BIT(1/2)?:");
ch=getch();
printf("%c\n",ch);
}while((ch > '2') || (ch < '1'));
stopbit=ch-'1';
com_tbl.stopbit=(char)ch;
do{
printf("\n\tPARITY:(0:NONE, 1:ODD, 2:EVEN)");
ch=getch();
printf("%c\n",ch);
}while((ch > '2') || (ch < '0'));
parity=ch-'0';
switch(parity){
case 0:
com_tbl.parity='N';
break;
case 1:
com_tbl.parity='O';
break;
case 2:
com_tbl.parity='E';
break;
}
HM_parameter(port,baud,stopbit,databit,parity);
HA_parameter(port,baud,stopbit,databit,parity);
HN_parameter(port,baud,stopbit,databit,parity);
do {
printf("\n\tNOW THE MR320 PROTOCOL IS (0:NULL,1:ACK/NAK,2:MULTI-POINT):");
ch=getch();
printf("%c",ch);
}while(ch>'2' || ch<'0');
protocol=ch-'0';
if (protocol==MULTI_PROTOCOL)
aSelectAddress();
else
address[0]='A';
while(1){
printf("\n\n\tMR320 EASY COMMUNICATION UTILITY %s\n",version);
printf("\tCom:%d \tBaud:%d \tStopbit:%d \tDatabit:%d \tParity:%s\n",\
port,baudtbl[baud],stopbit?2:1,databit?8:7,paritytbl[parity]);
printf("\tProtocol:%s ",prototbl[protocol]);
printf("\tAddress: ");
for(i=0;i<addr_count;i++)
putchar(address[i]);
putchar('\n');
printf(" 谀哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪目\n");
printf("
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -