Download Dynamic C Applications framework
Transcript
int Dwrite_z0( char* buffer, int count )
Copies count bytes from buffer to the transmit buffer. If the
transmit buffer is not already transmitting, the function initiates
transmission. It returns
0 transmit buffer did not have space for count bytes.
1 Write is successful.
void Dz0send_prompt()
Places CR, LF and > in the transmit buffer.
void Dreset_z0rbuf()
Resets the receive buffer.
void Dreset_z0tbuf()
Resets the transmit buffer and stops transmission.
void Dkill_z0()
Disables Z180 Port 0.
Sample Program
This example shows RS-232 communication between a controller and a
PC functioning as a dumb terminal.
#define CR 0x0d
char baud = 8;
char mode = 4;
char
char
char
char
ismodem = 0;
isecho = 1;
tbuf[384];
rbuf[200];
//
//
//
//
//
//
//
//
//
carriage return
9600 baud, divided by 1200
1 stop bit
no parity
8 data bits
no modem is connected
data received are echoed
circ. transmit buffer
circ. receive buffer
main(){
char buf[20];
// messages
Dinit_z0(rbuf,tbuf,200,384,mode,baud,ismodem,isecho);
Dz0send_prompt(); // send a prompt
while(1){
// wait for a message terminated with CR
while( Dread_z0(buf,CR)==0 );
// here you could do whatever you want with the message
// in this example, the message is sent back
Dz0send_prompt();
Dwrite_z0(buf,strlen(buf)); // send message back
// then, some more ...
Dz0send_prompt();
Dwrite_z0(it works!,9);
// write another
Dz0send_prompt();
}
}
Application Frameworks
RS-232 Communication s 69