static int ReadChannel(InStoreStruct *setup, int *max_samps_ptr, int chan, int *samples_ptr, short *data_ptr) { short *in_ptr = data_ptr; short *end_ptr = data_ptr + *samples_ptr; int pnts_to_read; struct { unsigned short status; unsigned short bytcnt; unsigned short fill[2]; } iosb; int lamchks = 10; unsigned short dum_read; int status; pio(10,0,0); pio(16,chan,&zero); while (pnts_to_read = max(0,min(32767,end_ptr-in_ptr))) { return_on_error(DevCamChk(CamQrepw(setup->name,0,2,pnts_to_read,in_ptr,16,0),&one,0),status); CamGetStat((short *)&iosb); if ((!(CamQ((short *)&iosb)&1)) && (iosb.bytcnt == 0)) in_ptr = end_ptr; else in_ptr += iosb.bytcnt/2; } if (*max_samps_ptr != *samples_ptr) { pio(24,0,0); pio(2,0,&dum_read); pio(26,0,0); } while (lamchks) { pio(8,0,0); if (CamQ(0)&1) lamchks = 0; else lamchks--; } return 1; }
int l8206___store(struct descriptor *niddsc_ptr, InStoreStruct *setup) { int status; int savstatus; int upload_nid = setup->head_nid + L8206_N_UPLOAD; pio(19,&zero); if (TreeIsOn(upload_nid)&1) { int numpoints = 0; short *bptr; int pread; pio(8,0); if (CamQ(0) & 1) { numpoints = 65536; } else { pio(0,&numpoints); } pio(25,0); pio(18,&zero); pio(2,&buffer[0]); /* junk word */ for (pread = 0,bptr = buffer; pread < numpoints;) { int num = numpoints - pread; if (num > 32767) num = 32767; stop(2,num,bptr); pread += num; bptr += num; } if (numpoints > 0) { data.arsize = numpoints * sizeof(short); status = TreePutRecord(upload_nid,(struct descriptor *)&data,0); } else status = L8206$_NODATA; } savstatus = status; pio(18,&zero); pio(11,&zero); pio(26,&zero); if (status & 1) status = savstatus; return status; }