本文整理汇总了C++中HexDump函数的典型用法代码示例。如果您正苦于以下问题:C++ HexDump函数的具体用法?C++ HexDump怎么用?C++ HexDump使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HexDump函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LogExcess
int USBRelayOutput::RawSendData(unsigned char *channelData)
{
LogExcess(VB_CHANNELOUT, "USBRelayOutput::RawSendData(%p)\n", channelData);
char out = 0x00;
int shiftBits = 0;
for (int i = 0; i < m_relayCount; i++)
{
if ((i > 0) && ((i % 8) == 0))
{
// Write out previous byte
HexDump("out", &out, 1);
write(m_fd, &out, 1);
out = 0x00;
shiftBits = 0;
}
out |= (channelData[i] ? 1 : 0) << shiftBits;
shiftBits++;
}
// Write out any unwritten bits
if (m_relayCount)
{
write(m_fd, &out, 1);
HexDump("out", &out, 1);
}
return m_relayCount;
}
示例2: FalconQueryHardware
void FalconQueryHardware(int sock, struct sockaddr_in *srcAddr,
struct in_addr recvAddr, unsigned char *inBuf)
{
LogDebug(VB_SETTING, "FalconQueryHardware(%p)\n", inBuf);
// Return config information, Falcon hardware info, network IP info, etc.
char buf[60];
bzero(buf, sizeof(buf));
char query[FALCON_CFG_BUF_SIZE];
int responseSize = FalconDetectHardware(0, query);
if (responseSize == FALCON_CFG_BUF_SIZE)
{
// Stuff response into our response packet. We could use memcpy, but
// this helps document what the returned bytes are.
buf[52] = query[0]; // Hardware ID
buf[53] = query[1]; // Firmware Major Version
buf[54] = query[2]; // Firmware Minor Version
buf[55] = query[3]; // Chip Temperature
buf[56] = query[4]; // Temperature #1
buf[57] = query[5]; // Temperature #2
buf[58] = query[6]; // Voltage #1
buf[59] = query[7]; // Voltage #2
if ((logLevel & LOG_DEBUG) && (logMask & VB_SETTING))
HexDump("Falcon Hardware Query Info Response", query, 8);
}
else
{
LogErr(VB_SETTING, "Error retrieving hardware data via SPI\n");
}
buf[0] = 0x55;
buf[1] = 0x55;
buf[2] = 0x55;
buf[3] = 0x55;
buf[4] = 0x55;
buf[5] = inBuf[5];
buf[6] = 0x00; // Query Info command response
PopulatePiConfig(inet_ntoa(recvAddr), buf);
if ((logLevel & LOG_DEBUG) && (logMask & VB_SETTING))
HexDump("Falcon Query Hardware result", buf, sizeof(buf));
if(sendto(sock, buf, sizeof(buf), 0, (struct sockaddr*)srcAddr, sizeof(*srcAddr)) < 0)
{
LogDebug(VB_SETTING, "ERROR: sentto failed\n");
}
}
示例3: FalconConfigurePi
void FalconConfigurePi(int sock, struct sockaddr_in *srcAddr,
struct in_addr recvAddr, unsigned char *inBuf)
{
LogDebug(VB_SETTING, "FalconConfigurePi(%p)\n", inBuf);
// Parse Network/IP info from received data and configure Pi
char buf[53];
bzero(buf, sizeof(buf));
buf[0] = 0x55;
buf[1] = 0x55;
buf[2] = 0x55;
buf[3] = 0x55;
buf[4] = 0x55;
buf[5] = inBuf[5];
buf[6] = 0x03; // Configure Pi command response
PopulatePiConfig(inet_ntoa(recvAddr), buf);
if ((logLevel & LOG_DEBUG) && (logMask & VB_SETTING))
HexDump("Falcon Configure Pi result", buf, sizeof(buf));
if(sendto(sock, buf, sizeof(buf), 0, (struct sockaddr*)srcAddr, sizeof(*srcAddr)) < 0)
{
LogDebug(VB_SETTING, "ERROR: sentto failed\n");
}
}
示例4: FalconGetData
void FalconGetData(int sock, struct sockaddr_in *srcAddr, unsigned char *inBuf)
{
LogDebug(VB_SETTING, "FalconGetData(%p)\n", inBuf);
char buf[FALCON_CFG_FILE_MAX_SIZE];
char filename[16];
switch ((unsigned char)inBuf[5])
{
case 0xCC: strcpy(filename, "Falcon.FPD");
break;
case 0xCD: strcpy(filename, "Falcon.F16V2-alpha");
break;
}
int bytes = FalconReadConfig(filename, buf);
buf[6] = 0x02; // GetData command response
if ((logLevel & LOG_DEBUG) && (logMask & VB_SETTING))
HexDump("Falcon Get Data result", buf, 8);
if(sendto(sock, buf, bytes, 0, (struct sockaddr*)srcAddr, sizeof(*srcAddr)) < 0)
{
LogDebug(VB_SETTING, "ERROR: sentto failed\n");
}
}
示例5: SendFPDConfig
void SendFPDConfig()
{
int i,index;
unsigned char bufferPixelnetDMX[PIXELNET_DMX_BUF_SIZE];
memset(bufferPixelnetDMX,0,PIXELNET_DMX_BUF_SIZE);
memcpy(bufferPixelnetDMX,PixelnetDMXcontrolHeader,PIXELNET_HEADER_SIZE);
index = PIXELNET_HEADER_SIZE;
for(i=0;i<pixelnetDMXcount;i++)
{
bufferPixelnetDMX[index++] = pixelnetDMX[i].type;
bufferPixelnetDMX[index++] = (char)(pixelnetDMX[i].startChannel%256);
bufferPixelnetDMX[index++] = (char)(pixelnetDMX[i].startChannel/256);
}
if (LogMaskIsSet(VB_CHANNELOUT) && LogLevelIsSet(LOG_DEBUG))
HexDump("FPD Config Header & Data", bufferPixelnetDMX,
PIXELNET_HEADER_SIZE + (pixelnetDMXcount*3));
i = wiringPiSPIDataRW (0, (unsigned char *)bufferPixelnetDMX, PIXELNET_DMX_BUF_SIZE);
if (i != PIXELNET_DMX_BUF_SIZE)
LogErr(VB_CHANNELOUT, "Error: wiringPiSPIDataRW returned %d, expecting %d\n", i, PIXELNET_DMX_BUF_SIZE);
delayMicroseconds (10000) ;
// i = wiringPiSPIDataRW (0, bufferPixelnetDMX, PIXELNET_DMX_BUF_SIZE);
// if (i != PIXELNET_DMX_BUF_SIZE)
// LogErr(VB_CHANNELOUT, "Error: wiringPiSPIDataRW returned %d, expecting %d\n", i, PIXELNET_DMX_BUF_SIZE);
}
示例6: DVDreadBCA
s32 DVDreadBCA()
{
s32 s32result;
int i;
i = 0;
errno = 0;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDreadBCA()");
#endif /* VERBOSE_FUNCTION */
memset(&dvdbca, 0, sizeof(dvd_struct));
dvdbca.type = DVD_STRUCT_BCA;
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdbca);
if ((s32result == -1) || (errno != 0))
{
dvdbca.type = 0xFF;
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error getting BCA: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
return(-1);
} // ENDIF- Problem with read of physical data?
#ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: BCA Length %i Value:",
dvdbca.bca.len);
for (i = 0; i < 188 - 15; i += 16)
{
HexDump(dvdbca.bca.value + i, 16);
} // NEXT i- dumping whole key data
#endif /* VERBOSE_DISC_INFO */
return(0); // Success. BCA data stored for perusal.
} // END DVDreadBCA()
示例7: ReadResp
int ReadResp(int fd)
{
int len = 0;
struct timeval timeout;
int nfds = fd + 1;
fd_set readfds;
int select_ret;
FD_ZERO(&readfds);
FD_SET(fd, &readfds);
// Wait a second
timeout.tv_sec = 1;
timeout.tv_usec = 500000;
fprintf(stderr,"s");
while (select_ret = select(nfds, &readfds, NULL, NULL, &timeout) > 0)
{
fprintf(stderr,"1");
DEBUGLOG(fprintf(stderr,"select_ret = %d\n",select_ret));
len += read(fd, readbuf + len, BUFSIZE - len);
FD_ZERO(&readfds);
FD_SET(fd, &readfds);
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
}
if (len > 0) {
fprintf(stderr,"2");
DEBUGLOG(fprintf(LOG, "Read:\n"));
DEBUGLOG(HexDump(readbuf, len));
}
return len;
}
示例8: FalconSetData
void FalconSetData(int sock, struct sockaddr_in *srcAddr, unsigned char *inBuf)
{
LogDebug(VB_SETTING, "FalconSetData(%p)\n", inBuf);
char filename[16];
int len = 0;
int configureHardware = 1;
char buf[8];
buf[0] = 0x55;
buf[1] = 0x55;
buf[2] = 0x55;
buf[3] = 0x55;
buf[4] = 0x55;
buf[5] = inBuf[5];
buf[6] = 0x01; // Set Data command response
buf[7] = 0x00; // 0x00 = success, 0xFF = player busy, 0xFE SPI write failed
strcpy(filename, "unknown");
switch ((unsigned char)inBuf[5])
{
case 0xCC: strcpy(filename, "Falcon.FPD");
len = 1024;
break;
case 0xCD: strcpy(filename, "Falcon.F16V2-alpha");
len = 1024;
break;
}
FalconWriteConfig(filename, (char *)inBuf, len);
if (sequence->IsSequenceRunning())
{
if (inBuf[7] == 0x01)
{
playlist->StopNow();
}
else
{
configureHardware = 0;
buf[7] = 0xFF;
}
}
if (configureHardware)
{
int configResult = FalconConfigureHardware(filename, 0);
if (configResult != 0)
buf[7] = 0xFE;
}
if ((logLevel & LOG_DEBUG) && (logMask & VB_SETTING))
HexDump("Falcon Set Data result", buf, sizeof(buf));
if(sendto(sock, buf, sizeof(buf), 0, (struct sockaddr*)srcAddr, sizeof(*srcAddr)) < 0)
{
LogDebug(VB_SETTING, "ERROR: sentto failed\n");
}
}
示例9: TEST
TEST(HexDumpTest, TestFalse) {
std::shared_ptr<Builder> b = Parser::fromJson("false");
std::ostringstream out;
out << HexDump(b->slice());
ASSERT_EQ("0x19", out.str());
}
示例10: SendOutputBuffer
int SendOutputBuffer(FPDPrivData *privData)
{
LogDebug(VB_CHANNELDATA, "SendOutputBuffer()\n");
int i;
unsigned char *c = privData->outBuf + PIXELNET_HEADER_SIZE;
memcpy(privData->outBuf, PixelnetDMXdataHeader, PIXELNET_HEADER_SIZE);
pthread_mutex_lock(&privData->bufLock);
memcpy(c, privData->inBuf, PIXELNET_DMX_DATA_SIZE);
privData->dataWaiting = 0;
pthread_mutex_unlock(&privData->bufLock);
for(i = 0; i < PIXELNET_DMX_DATA_SIZE; i++, c++)
{
if (*c == 170)
{
*c = 171;
}
}
if (LogMaskIsSet(VB_CHANNELDATA) && LogLevelIsSet(LOG_EXCESSIVE))
HexDump("FPD Channel Header & Data", privData->outBuf, 256);
i = wiringPiSPIDataRW (0, privData->outBuf, PIXELNET_DMX_BUF_SIZE);
if (i != PIXELNET_DMX_BUF_SIZE)
{
LogErr(VB_CHANNELOUT, "Error: wiringPiSPIDataRW returned %d, expecting %d\n", i, PIXELNET_DMX_BUF_SIZE);
return 0;
}
return 1;
}
示例11: thdB
void thdB(void *pcn) {
char *recv_buf;
int recv_nbytes;
int cn;
int wc;
int pb;
cn=(int)pcn;
Log("%03d thdB thread begin...\n",cn);
while (1) {
Sleep(10);
recv_buf=(char *)Cbuf;
recv_nbytes=CSIZE;
wc=0;
while (1) {
pb=GetFromRBuf(cn,&cs_BBB,&BBB,recv_buf,recv_nbytes);
if (pb) {
Log("%03d recv %d bytes\n",cn,pb);
HexDump(cn,recv_buf,pb);
Sleep(1);
} else {
Sleep(1000);
}
if (No_Loop) break;//
wc++;
if (wc>3600) Log("%03d %d==wc>3600!\n",cn,wc);
}
if (No_Loop) break;//
}
}
示例12: DumpRawSectionData
//
// Do a hexadecimal dump of the raw data for all the sections. You
// could just dump one section by adjusting the PIMAGE_SECTION_HEADER
// and cSections parameters
//
void DumpRawSectionData(PIMAGE_SECTION_HEADER section,
PVOID base,
unsigned cSections)
{
unsigned i;
char name[IMAGE_SIZEOF_SHORT_NAME + 1];
printf("Section Hex Dumps\n");
for ( i=1; i <= cSections; i++, section++ )
{
// Make a copy of the section name so that we can ensure that
// it's null-terminated
memcpy(name, section->Name, IMAGE_SIZEOF_SHORT_NAME);
name[IMAGE_SIZEOF_SHORT_NAME] = 0;
// Don't dump sections that don't exist in the file!
if ( section->PointerToRawData == 0 )
continue;
printf( "section %02X (%s) size: %08X file offs: %08X\n",
i, name, section->SizeOfRawData, section->PointerToRawData);
HexDump( MakePtr(PBYTE, base, section->PointerToRawData),
section->SizeOfRawData );
printf("\n");
}
}
示例13: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
int retVal(0);
int arg = FindNextArg(argc, argv, 0);
if (arg <= 0)
{
Help();
retVal = 1;
}
else
{
for (int i = 1; i < argc; ++i)
_tprintf(_T("%s\n"), argv[i]);
BinaryFind bf;
{
BinaryData findBuffer;
findBuffer.BuildFromString(FindArgValue(argc, argv, _T("-f=")), FindArgValue(argc, argv, _T("-fs")) != NULL);
if (findBuffer.DataSize() > 0)
bf.SetFindPattern(findBuffer);
}
const TCHAR *fileOrString(argv[arg]);
if (Path(fileOrString).Exists()) {
Path filePath(fileOrString);
HDFDCB_Data cbData = { argc, argv, bf };
if (filePath.IsDir()) {
Finder f((FindCallBack)HEXDump_FindCallBack, &cbData,
FindArgValue(argc, argv, _T("-mp=")),
FindArgValue(argc, argv, _T("-ep=")));
f.StartFind(fileOrString);
}
else {
FindData fd(NULL, filePath, true);
HEXDump_FindCallBack(fd, &cbData);
}
if (cbData.nFiles > 1)
_tprintf(_T("Total files: %d\n"), cbData.nFiles);
if (cbData.nFound > 1) {
_tprintf(_T("Total files matching: %d\n"), cbData.nFound);
if (cbData.nMaxMatchPerFile > 1)
_tprintf(_T("max matching in a file : %d\n"), cbData.nMaxMatchPerFile);
}
}
else
{
if (bf.HasFindPattern()) {
bf.SetFindBuffer((const void *)fileOrString, _tcslen(fileOrString)*sizeof(fileOrString[0]));
while (true)
{
long long findPos = bf.FindNext();
if (findPos >= 0)
_tprintf(_T("%08llX\n"), findPos);
else break;
}
}
else
HexDump((const void *)fileOrString, _tcslen(fileOrString)*sizeof(fileOrString[0]));
}
}
return retVal;
}
示例14: DVDreadManufact
s32 DVDreadManufact()
{
s32 s32result;
u8 i;
int successflag;
int j;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDreadManufact()");
#endif /* VERBOSE_FUNCTION */
j = 0;
successflag = 0;
for (i = 0; i <= dvdphysical.physical.layer_num; i++)
{
memset(&dvdmanufact[i], 0, sizeof(dvd_struct));
dvdmanufact[i].type = DVD_STRUCT_MANUFACT;
dvdmanufact[i].manufact.layer_num = i;
errno = 0;
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdmanufact[i]);
if ((s32result != 0) || (errno != 0))
{
dvdmanufact[i].type = 0xFF;
}
else
{
successflag = 1;
} // ENDIF- Did we fail to read in some manufacturer data?
} // NEXT i- Collecting manufacturer data from all layers
if (successflag == 0)
{
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error getting Manufact: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
return(-1);
} // ENDIF- Problem with read of physical data?
#ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: Manufact Data");
for (i = 0; i <= dvdphysical.physical.layer_num; i++)
{
if (dvdmanufact[i].type != 0xFF)
{
PrintLog("CDVD driver: Layer %i Length %i Value:",
dvdmanufact[i].manufact.layer_num,
dvdmanufact[i].manufact.len);
for (j = 0; j < 128 - 15; j += 16)
{
HexDump(dvdmanufact[i].manufact.value + j, 16);
} // NEXT j- dumping whole key data
} // ENDIF- Do we have data at this layer?
} // NEXT i- Running through all the layers
#endif /* VERBOSE_DISC_INFO */
errno = 0;
return(0); // Success. Manufacturer's data stored for perusal.
} // END DVDreadManufact()
示例15: LogFormat
size_t
DumpPort::Write(const void *data, size_t length)
{
LogFormat("Write(%u)", (unsigned)length);
size_t nbytes = port->Write(data, length);
LogFormat("Write(%u)=%u", (unsigned)length, (unsigned)nbytes);
HexDump("W ", data, nbytes);
return nbytes;
}