本文整理汇总了C++中readData函数的典型用法代码示例。如果您正苦于以下问题:C++ readData函数的具体用法?C++ readData怎么用?C++ readData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readData
long double Interface::readInput(std::string search) {
std::vector<long double> out;
out = readData(search);
return out[0];
}
示例2: readData
uint32_t RTCMemStore::getMillis() {
readData();
uint32_t x = rtcData->millisStartIteration;
updateData();
return x;
}
示例3: ReadTapeBlock
static afs_int32
ReadTapeBlock(struct butm_tapeInfo *info,
char *buffer, /* assumed to be 16384 bytes */
afs_int32 *blockType)
{
afs_int32 code = 0;
afs_int32 rsize, fmtype;
struct tapeLabel *label;
struct fileMark *fmark;
struct blockMark *bmark;
struct progress *p;
*blockType = BLOCK_UNKNOWN;
p = (struct progress *)info->tmRock;
memset(buffer, 0, BUTM_BLOCKSIZE);
label = (struct tapeLabel *)buffer;
fmark = (struct fileMark *)buffer;
bmark = (struct blockMark *)buffer;
rsize = readData(p->fid, buffer, BUTM_BLOCKSIZE, &info->error);
if (rsize > 0) {
incPosition(info, p->fid, rsize);
p->reading++;
}
if (rsize == 0) { /* Read a HW EOF Marker? OK */
*blockType = BLOCK_EOF;
incSize(info, config.fileMarkSize); /* Size of filemark */
if (!isafile)
info->position++; /* bump position */
p->reading = 0; /* No reads since EOF */
}
else if (rsize != BUTM_BLOCKSIZE) { /* Didn't Read a full block */
info->status |= BUTM_STATUS_READERROR;
ERROR_EXIT((rsize < 0) ? BUTM_IO : BUTM_EOT);
}
else if (ntohl(bmark->magic) == BLOCK_MAGIC) { /* Data block? */
*blockType = BLOCK_DATA;
}
else if (ntohl(fmark->magic) == FILE_MAGIC) { /* Read a filemark? */
fmtype = ntohl(fmark->nBytes);
if (fmtype == FILE_BEGIN) { /* filemark begin */
*blockType = BLOCK_FMBEGIN;
} else if (fmtype == FILE_FMEND) { /* filemark end */
*blockType = BLOCK_FMEND;
code = SeekFile(info, 1);
} else if (fmtype == FILE_EOD) { /* EOD mark */
*blockType = BLOCK_EOD;
info->status |= BUTM_STATUS_EOD;
code = SeekFile(info, 1);
}
}
else if (ntohl(label->magic) == TAPE_MAGIC) { /* Read a tape label? */
*blockType = BLOCK_LABEL;
code = SeekFile(info, 1);
}
if (isafile)
info->position++;
error_exit:
return (code);
}
示例4: show_mask1
int show_mask1(PARAM *p)
{
DATA d;
char event[MAX_EVENT_LENGTH];
char text[MAX_EVENT_LENGTH];
char str1[MAX_EVENT_LENGTH];
int i,w,h,val,x,y,button,ret;
float xval, yval;
defineMask(p);
//rlSetDebugPrintf(1);
if((ret=slotInit(p,&d)) != 0) return ret;
readData(&d); // from shared memory, database or something else
showData(p,&d);
pvClearMessageQueue(p);
while(1)
{
pvPollEvent(p,event);
switch(pvParseEvent(event, &i, text))
{
case NULL_EVENT:
readData(&d); // from shared memory, database or something else
showData(p,&d);
if((ret=slotNullEvent(p,&d)) != 0) return ret;
break;
case BUTTON_EVENT:
if(trace) printf("BUTTON_EVENT id=%d\n",i);
if((ret=slotButtonEvent(p,i,&d)) != 0) return ret;
break;
case BUTTON_PRESSED_EVENT:
if(trace) printf("BUTTON_PRESSED_EVENT id=%d\n",i);
if((ret=slotButtonPressedEvent(p,i,&d)) != 0) return ret;
break;
case BUTTON_RELEASED_EVENT:
if(trace) printf("BUTTON_RELEASED_EVENT id=%d\n",i);
if((ret=slotButtonReleasedEvent(p,i,&d)) != 0) return ret;
break;
case TEXT_EVENT:
if(trace) printf("TEXT_EVENT id=%d %s\n",i,text);
if((ret=slotTextEvent(p,i,&d,text)) != 0) return ret;
break;
case SLIDER_EVENT:
sscanf(text,"(%d)",&val);
if(trace) printf("SLIDER_EVENT val=%d\n",val);
if((ret=slotSliderEvent(p,i,&d,val)) != 0) return ret;
break;
case CHECKBOX_EVENT:
if(trace) printf("CHECKBOX_EVENT id=%d %s\n",i,text);
if((ret=slotCheckboxEvent(p,i,&d,text)) != 0) return ret;
break;
case RADIOBUTTON_EVENT:
if(trace) printf("RADIOBUTTON_EVENT id=%d %s\n",i,text);
if((ret=slotRadioButtonEvent(p,i,&d,text)) != 0) return ret;
break;
case GL_INITIALIZE_EVENT:
if(trace) printf("you have to call initializeGL()\n");
if((ret=slotGlInitializeEvent(p,i,&d)) != 0) return ret;
break;
case GL_PAINT_EVENT:
if(trace) printf("you have to call paintGL()\n");
if((ret=slotGlPaintEvent(p,i,&d)) != 0) return ret;
break;
case GL_RESIZE_EVENT:
sscanf(text,"(%d,%d)",&w,&h);
if(trace) printf("you have to call resizeGL(w,h)\n");
if((ret=slotGlResizeEvent(p,i,&d,w,h)) != 0) return ret;
break;
case GL_IDLE_EVENT:
if((ret=slotGlIdleEvent(p,i,&d)) != 0) return ret;
break;
case TAB_EVENT:
sscanf(text,"(%d)",&val);
if(trace) printf("TAB_EVENT(%d,page=%d)\n",i,val);
if((ret=slotTabEvent(p,i,&d,val)) != 0) return ret;
break;
case TABLE_TEXT_EVENT:
sscanf(text,"(%d,%d,",&x,&y);
pvGetText(text,str1);
if(trace) printf("TABLE_TEXT_EVENT(%d,%d,\"%s\")\n",x,y,str1);
if((ret=slotTableTextEvent(p,i,&d,x,y,str1)) != 0) return ret;
break;
case TABLE_CLICKED_EVENT:
sscanf(text,"(%d,%d,%d)",&x,&y,&button);
if(trace) printf("TABLE_CLICKED_EVENT(%d,%d,button=%d)\n",x,y,button);
if((ret=slotTableClickedEvent(p,i,&d,x,y,button)) != 0) return ret;
break;
case SELECTION_EVENT:
sscanf(text,"(%d,",&val);
pvGetText(text,str1);
if(trace) printf("SELECTION_EVENT(column=%d,\"%s\")\n",val,str1);
if((ret=slotSelectionEvent(p,i,&d,val,str1)) != 0) return ret;
break;
case CLIPBOARD_EVENT:
sscanf(text,"(%d",&val);
if(trace) printf("CLIPBOARD_EVENT(id=%d)\n",val);
if(trace) printf("clipboard = \n%s\n",p->clipboard);
if((ret=slotClipboardEvent(p,i,&d,val)) != 0) return ret;
break;
case RIGHT_MOUSE_EVENT:
if(trace) printf("RIGHT_MOUSE_EVENT id=%d text=%s\n",i,text);
//.........这里部分代码省略.........
示例5: while
int IptcParser::decode(
IptcData& iptcData,
const byte* pData,
uint32_t size
)
{
#ifdef DEBUG
std::cerr << "IptcParser::decode, size = " << size << "\n";
#endif
const byte* pRead = pData;
iptcData.clear();
uint16_t record = 0;
uint16_t dataSet = 0;
uint32_t sizeData = 0;
byte extTest = 0;
while (pRead + 3 < pData + size) {
// First byte should be a marker. If it isn't, scan forward and skip
// the chunk bytes present in some images. This deviates from the
// standard, which advises to treat such cases as errors.
if (*pRead++ != marker_) continue;
record = *pRead++;
dataSet = *pRead++;
extTest = *pRead;
if (extTest & 0x80) {
// extended dataset
uint16_t sizeOfSize = (getUShort(pRead, bigEndian) & 0x7FFF);
if (sizeOfSize > 4) return 5;
pRead += 2;
sizeData = 0;
for (; sizeOfSize > 0; --sizeOfSize) {
sizeData |= *pRead++ << (8 *(sizeOfSize-1));
}
}
else {
// standard dataset
sizeData = getUShort(pRead, bigEndian);
pRead += 2;
}
if (pRead + sizeData <= pData + size) {
int rc = 0;
if ((rc = readData(iptcData, dataSet, record, pRead, sizeData)) != 0) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to read IPTC dataset "
<< IptcKey(dataSet, record)
<< " (rc = " << rc << "); skipped.\n";
#endif
}
}
#ifndef SUPPRESS_WARNINGS
else {
EXV_WARNING << "IPTC dataset " << IptcKey(dataSet, record)
<< " has invalid size " << sizeData << "; skipped.\n";
}
#endif
pRead += sizeData;
}
return 0;
} // IptcParser::decode
示例6: while
/// Process data received by UART
///
void simpleBinary::processSerial()
{
while (serial->available() > 0)
{
int data = serial->read();
serbuf[serbuflen++] = data;
}
if(serbuflen > 3)
{
receiveTime = millis();
if(serbuf[0] == _uartAddress)
{
int address;
char crc;
switch(serbuf[1])
{
//new data
case (char)0xD0:
if(serbuf[2] == 0x01)
{
//force all output data as new through user function
forceAllNewData();
}
if(serbuf[2] == 0x00 || serbuf[2] == 0x01)
{
crc = CRC8::evalCRC(serbuf,3);
if(crc != serbuf[3])
sendWrongData(crc);
else
checkNewData();
}
else
sendUnknownData();
serbuflen = 0;
break;
//read data
case (char)0xD1:
if(serbuflen < 5)
break;
address = serbuf[2] | (serbuf[3] << 8);
crc = CRC8::evalCRC(serbuf,4);
if(crc != serbuf[4])
sendWrongData(crc);
else
readData(address);
serbuflen = 0;
break;
//write byte
case (char)0xDA:
if(serbuflen < 6)
break;
//address
address = serbuf[2] | (serbuf[3] << 8);
//crc check
crc = CRC8::evalCRC(serbuf,5);
if(serbuf[5] != crc)
sendWrongData(crc);
else
{
//check address
if(!checkAddress(address))
sendInvalidAddress();
//write data into memory
if(saveByte(address,serbuf+4))
sendOK();
else
sendSavingError();
}
//clear buffer
serbuflen = 0;
break;
//write word
case (char)0xDB:
if(serbuflen < 7)
break;
//address
address = serbuf[2] | (serbuf[3] << 8);
//crc check
crc = CRC8::evalCRC(serbuf,6);
if(serbuf[6] != crc)
sendWrongData(crc);
else
{
//check address
if(!checkAddress(address))
sendInvalidAddress();
//write data into memory
//.........这里部分代码省略.........
示例7: sendCommand
int SRF02::getDistance(){
sendCommand(_deviceId, _mode);
delay(READ_DURATION);
setRegister(_deviceId, RESULT_REGISTER);
return readData(_deviceId, 2);
}
示例8: main
//Beginning of main(void)
int main(void)
{
//Initializes variables
struct holeStruct holeData[MAX_HOLES];
struct dimenssionStruct dimenssion;
struct dimenssionStruct*dimenPtr=&dimenssion;
char label1[50];
char label2[50];
float inputDepth=0;
//Holds input indicating if user wants to run or quit the program
int mainChoice=0;
//This hold the value (as returned by scanf()) indicating number of assignments made
int validDepth=0;
int soilChoice=0;
int readResult=0;
//result from readData function is stored in readResult var.
readResult=readData(holeData,label1,label2);
switch(readResult)
{
case 0:
{
//If readResult=0, below code is executed
calcDimen(holeData,dimenPtr);
calcHoleCoord(holeData,dimenPtr);
initGraphics(dimenPtr);
showAllData(holeData,label1,label2,dimenPtr);
setcolor(WHITE);
outtextxy(2,2,"Enter a depth in the console to see the soil information at that depth here.");
/*This do..while loop calls the routines inside it
as long as user does not decide to quit the program*/
do{
mainChoice=displayMainMenu();
if(mainChoice==1)
{
do
{
printf("\nEnter a depth (in meters):");
fflush(stdin);
validDepth=scanf("%f",&inputDepth);
}while(validDepth==0);
inputDepth=fabs(inputDepth);
soilChoice=displaySoilMenu();
processPrint(holeData,inputDepth,label1,label2,dimenPtr,soilChoice,1);
}
}while(mainChoice!=2);
//.........这里部分代码省略.........
示例9: main
/**
* Main program
*
* @param argc number of arguments passed to the program
* @param argv array of arguments passed to the program
*
* @return status
*/
int main (int argc, char** argv)
{
char optstring[] = "n:t:o:va";
unsigned int i;
unsigned char previousBit;
struct timeval* start;
int option;
unsigned int duration = 80;
unsigned long int samples = 50000;
unsigned char verbose = 0;
unsigned char all = 0;
FILE* output=0;
BYTE_BUFFER buffer;
/* reading options */
opterr=0; /* Pas de message d'erreur automatique */
while ((option = getopt(argc, argv, optstring)) != -1) {
switch (option) {
case 't':
sscanf(optarg, "%d", &duration);
break;
case 'n':
sscanf(optarg, "%lu", &samples);
break;
case 'a':
all = 1;
break;
case 'v':
verbose = 1;
break;
case 'o':
output = fopen(optarg, "w");
if (output==0) {
fprintf(stderr, "Could not open file %s\n", optarg);
}
break;
default:
usage(argv);
return 0;
break;
}
}
/* Configure the GPIO */
initIO();
/* Read the data */
fprintf(stderr, "Reading data\n");
buffer = readData(samples, duration);
/* Analyzing the data */
fprintf(stderr, "Analyzing\n");
analyse(buffer, output ? output : stdout, all);
if (verbose) {
fprintf(output ? output : stdout, "\n\nRawData\n");
previousBit=0;
for(i=0; i<buffer.size; i++) {
if ((previousBit == 0) && (buffer.data[i] == 1))
fprintf(output ? output : stdout, "\n");
fprintf(output ? output : stdout, "%c", buffer.data[i]+'0');
previousBit = buffer.data[i];
}
}
destroyByteBuffer(buffer);
return 0 ;
}
示例10: main
int main(int argc, char** argv){
int i,j, *NNs;
double **x,**q, bbtime, brutetime,*dToNNs,divTemp;
treenode *root;
struct timeval tvB,tvE;
printf("**** bbtree **** \n");
processArgs(argc,argv);
x = calloc(n,sizeof(double*));
q = calloc(m,sizeof(double*));
for(i=0;i<n;i++)
x[i]=calloc(d,sizeof(double));
for(i=0;i<m;i++)
q[i]=calloc(d,sizeof(double));
dToNNs = calloc(k,sizeof(double));
NNs = calloc(k,sizeof(int));
readData(x,n,d,datafile);
readData(q,m,d,queryfile);
bregdiv div;
switch(divChoice){
case USEL2:
div = l2squared();
printf("divergence = l_2^2\n");
break;
case USEKL:
div = kl();
printf("divergence = KL\n");
break;
case USEKLD:
div = dkl();
printf("divergence = conjugate to KL\n");
printf("WARNING: this has not been tested thoroughly\n");
break;
case USEIS:
div = is();
printf("divergence = Itakura-Saito\n");
printf("WARNING: this has not been tested thoroughly\n");
break;
}
printf("building.....\n");
gettimeofday(&tvB,NULL);
root = buildTree(x,n,d,div,bucketSize);
gettimeofday(&tvE,NULL);
printf("done... build time: %6.2f \n",timediff(tvB,tvE));
gettimeofday(&tvB,NULL);
multisearch(root,q,x,div,n,d,m,eps,k,INT_MAX);
gettimeofday(&tvE,NULL);
bbtime = timediff(tvB,tvE);
printf("BBTREE time elapsed = %6.3f \n",bbtime);
//Example of how to save & retrieve a bbtree:
/*writeTree(root,d,"treefile.txt");
deleteTree(root);
root = readTree("treefile.txt");
gettimeofday(&tvB,NULL);
multisearch(root,q,x,div,n,d,m,eps,0,1);
gettimeofday(&tvE,NULL);
bbtime = timediff(tvB,tvE);
printf("BBTREE time elapsed = %6.3f \n",bbtime);
*/
//brute force
double curmin;
int curBest;
gettimeofday(&tvB,NULL);
for(i=0;i<m;i++){
for(j=0;j<k;j++){
dToNNs[j]=HUGE_VAL;
NNs[j]=-1;
}
curmin=HUGE_VAL;
curBest=-1;
for(j=0;j<n;j++){
divTemp = div.div(x[j],q[i],d);
if(NNs[0]==-1 || divTemp < dToNNs[0]){
insert(NNs,dToNNs,j,divTemp,k);
}
}
/* printf("query %d nns are \n",i);
for(j=0;j<k;j++)
printf("%d ",NNs[j]);
printf("\n"); */
}
gettimeofday(&tvE,NULL);
brutetime = timediff(tvB,tvE);
printf("BRUTE time elapsed = %6.3f \n",brutetime);
if(isOutfile){
writeDoubs(2,outfile,bbtime,brutetime);
}
//.........这里部分代码省略.........
示例11: readReg
uint8_t readReg(uint8_t reg)
{
writeCommand(reg);
return readData();
}
示例12: main
int main(){
//set up moves
Move moves[4] ={{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
//set up hash table
HashTable *hashTable;
HashTable *queueTable;
int tableSize = pow(SIZE, 9) - SIZE + 1;
int nos[SIZE * SIZE];
int g[SIZE * SIZE];
char *nums = (char *)calloc(SIZE * SIZE, sizeof(char));
//char nums[9] = {'7', '2', '4', '5', '6', '0', '8', '3', '1'};
nums = readData();
char *gl = (char *)calloc(SIZE * SIZE, sizeof(char));
//char gl[9] = {'2', '4', '1', '7', '8', '6', '5', '0', '3'};
gl = readData();
int i;
//converts char* to int*
for(i = 0; i < SIZE * SIZE; i++) nos[i] = (int)nums[i] - '0';
for(i = 0; i < SIZE * SIZE; i++) g[i] = (int)gl[i] - '0';
goal = (Board *)calloc(1, sizeof(Board));
insertTiles(goal, g);
setNumbers(goal);
start = (Board *)calloc(1, sizeof(Board));
insertTiles(start, nos);
setNumbers(start);
start->depth = 0;
printf("\nSTART:\n");
printBoard(start);
printf("\nGOAL:\n");
printBoard(goal);
Queue *queue;
Board *newBoard;
int f;
for (f = 0; f < 5; f++){
success = 0;
hashTable = (HashTable *)createHashTable(tableSize);
queueTable = (HashTable *)createHashTable(tableSize);
solution = (Board *)calloc(1, sizeof(Board));
Board *board = (Board *)calloc(1, sizeof(Board));
board = start;
switch(f){
case 0:
board->f = getH(board);
break;
case 1:
board->f = getHout(board);
break;
case 2:
board->f = getHmanhattan(board);
break;
case 3:
board->f = getHgreat2(board);
break;
case 4:
board->f = getHgreat3(board);
break;
default:
printf("error\n");
}
//set up queue
queue = (Queue *)createQueue();
int error;
if((error = insert(queue, board)) == 1){
printf("failed to insert starting board\n");
exit(1);
}
Node *current;
//Board *newBoard;
int m;
int fVal;
int tries = 0;
//iterate through queue until done
while(!success){
current = queue->head;
if((fVal = lookupBoard(hashTable, current->b)) == -1) {
if((error = addBoard(hashTable, current->b)) == 1) {
printf("failed to add board to hashtable\n");
exit(1);
}
//moves
for(m = 0; m < 4; m++){
if(!success) {
if((newBoard = makeBoardOnMove(current, moves[m], f)) != NULL){
if(newBoard->value == goal->value){
success = 1;
solution = newBoard;
}
if((fVal = lookupBoard(queueTable, newBoard)) == -1){
tries++;
if((error = insert(queue, newBoard)) == 1) {
printf("failed to insert new board\n");
exit(1);
}
if((error = addBoard(queueTable, newBoard)) == 1) {
printf("failed to add new Board to queuetable\n");
exit(1);
}
} else if(newBoard->f < fVal) {
//.........这里部分代码省略.........
示例13: graphicsMode
/********************************f******************************************/
void graphicsMode(void) {
writeCommand(RA8875_MWCR0);
uint8_t temp = readData();
temp &= ~RA8875_MWCR0_TXTMODE; // bit #7
writeData(temp);
}
示例14: writeCommand
uint16_t TFTLCD::readRegister(uint16_t addr) {
writeCommand(addr);
return readData();
}
示例15: main
int main(int argc, char **argv)
{
TSS_RESULT tResult;
TSS_HTPM hTpm;
TSS_HKEY hEk;
TSS_FLAG fEkAttrs;
int iRc = -1;
#ifdef TSS_LIB_IS_12
struct option opts[] = {{"revocable", no_argument, NULL, 'r'},
{"generate-secret", no_argument, NULL, 'g'},
{"infile", required_argument, NULL, 'i'},
{"outfile", required_argument, NULL, 'o'},
};
UINT32 revDataSz;
BYTE revokeData[TPM_SHA1BASED_NONCE_LEN];
BYTE *pRevData;
#endif
initIntlSys();
#ifdef TSS_LIB_IS_12
if (genericOptHandler(argc, argv, "rgi:o:", opts, sizeof(opts) / sizeof(struct option),
parse, help) != 0)
goto out;
//Check commands for command hierarchy
if (isRevocable) {
if (needGenerateSecret) {
if (!outFileSet) {
logError(_("Please specify an output file\n"));
goto out;
}
if (inFileSet) {
logError(_("The option -i, --infile is not valid with -g\n"));
goto out;
}
} else if (!inFileSet) {
logError(_("Please specify -i, --infile or -g, --generate-secret\n"));
goto out;
} else if (outFileSet) {
logError(_("The option -o, --outfile is not valid with -i, --infile"));
goto out;
}
}
logDebug("Input file name: %s\n", in_filename);
logDebug("Output file name: %s\n", out_filename);
if (inFileSet) {
pRevData = revokeData;
revDataSz = sizeof(revokeData);
if (readData(revDataSz, &pRevData))
goto out;
} else if (outFileSet) {
FILE *outfile = fopen(out_filename, "w");
if (!outfile) {
iRc = -1;
logError(_("Unable to open output file: %s\n"), out_filename);
goto out;
}
fclose(outfile);
//TPM should generate the revoke data
revDataSz = 0;
pRevData = NULL;
}
#else
if (genericOptHandler(argc, argv, NULL, NULL, 0, NULL, NULL) != 0){
logError(_("See man pages for details.\n"));
goto out;
}
#endif
if (contextCreate(&hContext) != TSS_SUCCESS)
goto out;
if (contextConnect(hContext) != TSS_SUCCESS)
goto out_close;
if (contextGetTpm(hContext, &hTpm) != TSS_SUCCESS)
goto out_close;
//Initialize EK attributes here
fEkAttrs = TSS_KEY_SIZE_2048 | TSS_KEY_TYPE_LEGACY;
if (contextCreateObject(hContext, TSS_OBJECT_TYPE_RSAKEY, fEkAttrs, &hEk) != TSS_SUCCESS)
goto out_close;
#ifdef TSS_LIB_IS_12
if (isRevocable){
tResult = tpmCreateRevEk(hTpm, hEk, NULL, &revDataSz, &pRevData);
if (tResult != TSS_SUCCESS)
goto out_close;
//Writes the generated secret into the output file
if (outFileSet) {
if (writeData(revDataSz, pRevData)) {
logError(_("Creating revocable EK succeeded, but writing the EK "
"revoke authorization to disk failed.\nPrinting the "
"revoke authorization instead:\n"));
logHex(revDataSz, pRevData);
logError(_("You should record this data, as its the authorization "
//.........这里部分代码省略.........