D-Series Syringe Pumps - Isco
D-Series Syringe Pumps - Isco
D-Series Syringe Pumps - Isco
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
D <strong>Series</strong> <strong>Syringe</strong> <strong>Pumps</strong><br />
Section 6 Serial Interface<br />
Table 6-3 Example of C program to demonstrate<br />
conversion of pump commands to DASNET frames<br />
#include<br />
#include<br />
#include "b:comm.c" /* edit to path needed */<br />
/* a ’C’ example of DASNET serial control */<br />
int conv_das();<br />
unsigned char in[256],out[256],buf[256];<br />
char unitnum;<br />
main()<br />
{<br />
unsigned port;<br />
int speed;<br />
cputs("ENTER UNIT ID="); /* get parms */<br />
scanf("%d",&unitnum);<br />
cputs("ENTER COM PORT=");<br />
scanf("%d",&port);<br />
cputs("ENTER BAUD RATE=");<br />
scanf("%d",&speed);<br />
comm_open(port,speed); /* open comm port */<br />
in[0]=50;<br />
cputs("ALL ENTRIES IN CAPS\n\r");<br />
while(1)<br />
cputs("\n\rENTER STRING(Q TO QUIT) >>>");<br />
cgets(in);<br />
if(in[2]==’Q’) break;<br />
conv_das(&in[2],out); /* convert string */<br />
cputs("\nDASNET FORMATTED OUTPUT >>>");<br />
puts(out); /* output converted string */<br />
comm_putc(0x0d); /* send "CR" to serial port */<br />
dput(out); /* output converted string to serial port */<br />
comm_putc(0x0d); /* end with a "CR" */<br />
dgets(buf); /* get response */<br />
cputs("\nDASNET RESPONSE >>>");<br />
puts(buf); /* output response */<br />
comm_flush(); /* flush serial buffer to start again */<br />
}<br />
comm_close();<br />
}<br />
/* dasnet conversion utility */<br />
conv_das(char *in, char *out)<br />
{<br />
unsigned sum;<br />
char *c_ptr;<br />
c_ptr=out; /* point to output */<br />
*out++=unitnum+0x30; /* put id first */<br />
*out++=’R’; /* add "R" to output */<br />
if (!strcmp(in,"R")) /* if just "R" add space to string */<br />
{<br />
*out++=’ ’;<br />
*out++=0x00;<br />
}<br />
else /* add # char to string */<br />
sprintf(out,"%3.3X%s",strlen(in),in);<br />
for (sum=0 ; *c_ptr; c_ptr++) /* add all chars together */<br />
sum+=*c_ptr;<br />
sum=(0x100 - sum) & 0x0FF; /* get check sum */<br />
sprintf(c_ptr,"%2.2X",sum); /* insert into string */<br />
}<br />
Note: Polling is part of the DASNET definition but is not required and is not shown in this example. This code was<br />
written in TC, version 4.5.<br />
6-5