Download User Manual SP232 Serial Extended Function Module (for 1502B/C
Transcript
Parallel Protocol
printf("\nEnter Op Code? ");
scanf("%3d", &command);
printf("\nEnter F for fixed or V for variable length command? ");
scanf("%1s", &leno);
leno = toupper(leno);
printf("\nEnter Response length? ");
scanf("%3d", &ilen);
printf("\nEnter Command frame length? ");
scanf("%3d", &olen);
crc = 0;
for( index = 1; index <= olen; index++)
{
printf("%s %d %s", "\nEnter data byte #", index, " = ");
scanf("%3d", &out[index]);
crc = 2 * crc;
crc = (crc + (crc / 256) + out[index]) & 255;
}
if (leno == 'V') printf("\n%s %d\n", "Variable Length CRC is:
", crc);
}
printf("\nPress space bar to return to Main Menu ");
getch();
acceptframe()
{
outp(PORT+3, 1);
ftype = getbyte();
switch(ftype)
{
case 0x10 :
case 0x20 :
case 0x30 :
{
command = getbyte();
leni = (command & 128) ? 'V' : 'F';
break;
}
case 0x40 :
{
command = getbyte();
ilen = 0;
6–14
SP232 User Manual