[:x] [:x] Hi, I have encountered a problem today.
Below is the code I used:
/**********************************************************
Connections:
============
1. Scanner to BL4S100: 2–RxD;3–TxD;5–Gnd.
2. BL4S100 to PLC: 2–RxF/CTS;3–TxF/RTS;5–Gnd.
**********************************************************/
#class auto // Change local var storage default to “auto”
// include BL4S1xx series library
#use “BL4S1xx.lib”
// serial buffer size
#define DINBUFSIZE 15
#define DOUTBUFSIZE 15
#define FINBUFSIZE 15
#define FOUTBUFSIZE 15
// serial baud rate
#ifndef _232BAUD
#define _232BAUD 9600
#endif
main()
{
int input, output, output2;
int i,j,iSend;
char PD_rbuf[DINBUFSIZE];
char PF_tbuf[FINBUFSIZE];
// initialize board (including serial ports)
brdInit();
// open serial ports
serDopen(_232BAUD);
serFopen(_232BAUD);
// Must use serial mode 0 for 3 wire RS232 operation and
// serMode must be executed after the serXopen function(s).
serMode(0);
// initialize parity
serFparity(PARAM_EPARITY);
//serDparity(PARAM_EPARITY);
// Clear serial data buffers
serDwrFlush();
serDrdFlush();
serFwrFlush();
serFrdFlush();
//printf("Start…
");
while (1)
{
i=0;
//Hits the watchdog timer, postponing a hardware reset for 2 seconds
hitwd();
input=serDgetc();
//Receive data from port D
if (input!=10 && input !=-1)
{
//printf("Received:%c
",input);
//for(j=0;j<1000;j++);
for(i=0;i