Пример #1
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
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
0
TEST(HexDumpTest, TestFalse) {
  std::shared_ptr<Builder> b = Parser::fromJson("false");
  std::ostringstream out;
  out << HexDump(b->slice());

  ASSERT_EQ("0x19", out.str());
}
Пример #10
0
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
0
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
0
//
// 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
0
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
0
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
0
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;
}
Пример #16
0
size_t
DumpPort::Write(const void *data, size_t length)
{
  LogStartUp(_T("Write(%u)"), (unsigned)length);
  size_t nbytes = port->Write(data, length);
  LogStartUp(_T("Write(%u)=%u"), (unsigned)length, (unsigned)nbytes);
  HexDump(_T("W "), data, nbytes);
  return nbytes;
}
Пример #17
0
void PrintRange(int starting_offset, int ending_offset)
{
    char plural[2] = "";
    int num_bytes_diff;

    assert(starting_offset >= 0);
    assert(starting_offset <= ending_offset);
    if (starting_offset < ending_offset) {
        strcpy(plural, "s");
    }
    num_bytes_diff = ending_offset - starting_offset + 1;
    fprintf(ofp, "File %s:  %d (0x%x) byte%s different\n", 
                 globals.filename1, num_bytes_diff, num_bytes_diff, plural);
    HexDump(globals.ifp1, starting_offset, num_bytes_diff);
    fprintf(ofp, "File %s:\n", globals.filename2);
    HexDump(globals.ifp2, starting_offset, num_bytes_diff);
    PrintSeparator();
}
Пример #18
0
void PacketLog::HexDumpStr(const char *msg, const char *data, size_t len, const char* file)
{
    FILE *pFile;
    pFile = fopen(file, "a");
    fprintf(pFile,"%s\n", msg);
    fclose(pFile);

    HexDump(data, len, file);
}
Пример #19
0
static int execute_set_tx_frequency_arm(char *szPort, UINT8 carrier_on, UINT16 tx_frequency, int tx_power)
{
    ComHelper SerialPort;

    if (!SerialPort.OpenPort(szPort))
    {
        printf("Open %s port Failed\n", szPort);
        return 0;
    }
    int chan_num = tx_frequency - 2400;
    UINT8 hci_set_tx_frequency_arm[] = {0x01, 0x014, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    UINT8 hci_set_tx_frequency_arm_cmd_complete_event[] = {0x04, 0x0e, 0x04, 0x01, 0x014, 0xfc, 0x00};
    hci_set_tx_frequency_arm[4] = (carrier_on == 0) ? 1 : 0;
    hci_set_tx_frequency_arm[5] = (carrier_on == 1) ? chan_num : 2;
    hci_set_tx_frequency_arm[6] = 0;                // unmodulated
    hci_set_tx_frequency_arm[7] = 0;                // modulation type  
    hci_set_tx_frequency_arm[8] = (carrier_on == 1) ? 8 : 0;
    hci_set_tx_frequency_arm[9] = tx_power;

    printf ("Sending HCI Command:\n");
    HexDump(hci_set_tx_frequency_arm, sizeof(hci_set_tx_frequency_arm));

    // write HCI reset
    SerialPort.Write(hci_set_tx_frequency_arm, sizeof(hci_set_tx_frequency_arm));

    // read HCI response header
    DWORD dwRead = SerialPort.Read((LPBYTE)&in_buffer[0], 3);

    // read HCI response payload
    if (dwRead == 3 && in_buffer[2] > 0)
        dwRead += SerialPort.Read((LPBYTE)&in_buffer[3], in_buffer[2]);

    printf ("Received HCI Event:\n");
    HexDump(in_buffer, dwRead);
    if (dwRead == sizeof(hci_set_tx_frequency_arm_cmd_complete_event))
    {
        if (memcmp(in_buffer, hci_set_tx_frequency_arm_cmd_complete_event, dwRead) == 0)
        {
            printf ("Success\n");
            return 1;
        }
    }
    return FALSE;
}
Пример #20
0
TEST(HexDumpTest, TestValuesPerLine) {
  std::shared_ptr<Builder> b = Parser::fromJson("[1,2,3,4,5,6,7,8,9,10]");
  std::ostringstream out;
  out << HexDump(b->slice(), 4, " ");

  ASSERT_EQ(
      "0x06 0x18 0x0a 0x31 \n0x32 0x33 0x34 0x35 \n0x36 0x37 0x38 0x39 \n0x28 "
      "0x0a 0x03 0x04 \n0x05 0x06 0x07 0x08 \n0x09 0x0a 0x0b 0x0c",
      out.str());
}
Пример #21
0
int
DumpPort::Read(void *buffer, size_t size)
{
  LogStartUp(_T("Read(%u)"), (unsigned)size);
  int nbytes = port->Read(buffer, size);
  LogStartUp(_T("Read(%u)=%d"), (unsigned)size, nbytes);
  if (nbytes > 0)
    HexDump(_T("R "), buffer, nbytes);
  return nbytes;
}
Пример #22
0
TEST(HexDumpTest, TestEmptySeparator) {
  std::shared_ptr<Builder> b = Parser::fromJson("[1,2,3,4,5,6,7,8,9,10]");
  std::ostringstream out;
  out << HexDump(b->slice(), 16, "");

  ASSERT_EQ(
      "0x060x180x0a0x310x320x330x340x350x360x370x380x390x280x0a0x030x04\n0x050x"
      "060x070x080x090x0a0x0b0x0c",
      out.str());
}
Пример #23
0
static void
recv_me (EIBNetIPPacket *p1)
{
  EIBnet_DescriptionResponse resp;
  if (parseEIBnet_DescriptionResponse (*p1, resp))
    die ("Invalid description response");
  printf ("Medium: %d\nState: %d\nAddr: %s\nInstallID: %d\nSerial:",
          resp.KNXmedium, resp.devicestatus,
          FormatEIBAddr (resp.individual_addr).c_str(), resp.installid);
  HexDump (resp.serial, sizeof (resp.serial));
  printf ("Multicast-Addr: %s\nMAC:", inet_ntoa (resp.multicastaddr));
  HexDump (resp.MAC, sizeof (resp.MAC));
  printf ("Name: %s\n", resp.name);
  printf ("Optional: ");
  HexDump (resp.optional.data(), resp.optional.size());
  ITER(i, resp.services)
    printf ("Service %d Version %d\n", i->family, i->version);
  ev_break(EV_DEFAULT_ EVBREAK_ALL);
}
Пример #24
0
int
DumpPort::Read(void *buffer, size_t size)
{
  LogFormat("Read(%u)", (unsigned)size);
  int nbytes = port->Read(buffer, size);
  LogFormat("Read(%u)=%d", (unsigned)size, nbytes);
  if (nbytes > 0)
    HexDump("R ", buffer, nbytes);
  return nbytes;
}
Пример #25
0
void SendCmd(int fd, void *buf, size_t size)
{
  DEBUGLOG(fprintf(LOG, "Sending:\n"));
  DEBUGLOG(HexDump((unsigned char*)buf, size));

  if(write(fd, buf, size) == -1) {
    fprintf(stderr, "Shit. %s\n", strerror(errno));
    exit(1);
  }
}
Пример #26
0
TEST(HexDumpTest, TestSeparator) {
  std::shared_ptr<Builder> b = Parser::fromJson("[1,2,3,4,5,6,7,8,9,10]");
  std::ostringstream out;
  out << HexDump(b->slice(), 16, ", ");

  ASSERT_EQ(
      "0x06, 0x18, 0x0a, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, "
      "0x28, 0x0a, 0x03, 0x04, \n0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, "
      "0x0c",
      out.str());
}
Пример #27
0
static int execute_le_transmitter_test(char *szPort, UINT8 chan_number, UINT8 length, UINT8 pattern)
{
    ComHelper SerialPort;

    if (!SerialPort.OpenPort(szPort))
	{
        printf("Open %s port Failed\n", szPort);
		return 0;
	}

    UINT8 hci_le_transmitter_test[] = {0x01, 0x01E, 0x20, 0x03, 0x00, 0x00, 0x00};
    UINT8 hci_le_transmitter_test_cmd_complete_event[] = {0x04, 0x0e, 0x04, 0x01, 0x01E, 0x20, 0x00};
    hci_le_transmitter_test[4] = chan_number;
    hci_le_transmitter_test[5] = length;
    hci_le_transmitter_test[6] = pattern;
    printf ("Sending HCI Command:\n");
    HexDump(hci_le_transmitter_test, sizeof(hci_le_transmitter_test));

    // write HCI reset
    SerialPort.Write(hci_le_transmitter_test, sizeof(hci_le_transmitter_test));

    // read HCI response header
    DWORD dwRead = SerialPort.Read((LPBYTE)&in_buffer[0], 3);

    // read HCI response payload
    if (dwRead == 3 && in_buffer[2] > 0)
        dwRead += SerialPort.Read((LPBYTE)&in_buffer[3], in_buffer[2]);

    printf ("Received HCI Event:\n");
    HexDump(in_buffer, dwRead);
    if (dwRead == sizeof(hci_le_transmitter_test_cmd_complete_event))
    {
        if (memcmp(in_buffer, hci_le_transmitter_test_cmd_complete_event, dwRead) == 0)
        {
            printf("Success\n");
			printf("LE Transmitter Test running, to stop execute le_test_end\n");
			return 1;
        }
    }
    return FALSE;
}
Пример #28
0
void test_sha1()
{
    const int N = 50000;
    const int M = 50000;

    int wit_failed = 0;
    u8 h1[100], h2[100], source[1000-21];
    printf("\n*** test SHA1 ***\n\n");

    int i;

    u32 t1 = GetTimerMSec();
    for ( i=0; i<M; i++ )
	SHA1(source,sizeof(source),h1);
    t1 = GetTimerMSec() - t1;

    u32 t2 = GetTimerMSec();
    for ( i=0; i<M; i++ )
	WIT_SHA1(source,sizeof(source),h2);
    t2 = GetTimerMSec() - t2;

    printf("WIT_SHA1: %8u msec / %u = %6llu nsec\n",t2,M,(u64)t2*1000000/M);
    printf("SHA1:     %8u msec / %u = %6llu nsec\n",t1,M,(u64)t1*1000000/M);

    for ( i = 0; i < N; i++ )
    {
	RandomFill(h1,sizeof(h1));
	memcpy(h2,h1,sizeof(h2));
	RandomFill(source,sizeof(source));

	SHA1(source,sizeof(source),h1);
	WIT_SHA1(source,sizeof(source),h2);

	if (memcmp(h2,h1,sizeof(h2)))
	    wit_failed++;
    }
    printf("WWT failed:%7u/%u\n\n",wit_failed,N);

    HexDump(stdout,0,0,0,24,h2,24);
    HexDump(stdout,0,0,0,24,h1,24);
}
Пример #29
0
static void ttfPrintNameRecordData(FILE *fp,NameRecordPtr rec)
{
    USHORT i,j;
    char hexbuf[100],ascbuf[100],*p;

    p = rec->data;
    for (i=0;i<rec->length/10;i++,p+=10)
	{
	    HexDump(p,hexbuf,ascbuf,10);
	    fprintf(fp,"\t\t %s >  %s\n",hexbuf,ascbuf);
	}
    HexDump(p,hexbuf,ascbuf,rec->length % 10);
    /* i know that this is ugly, but this makes output beautiful */
    i = strlen(hexbuf);
    for (j=i;j<30;j++)
	{
	    hexbuf[j] = ' ';
	}
    fprintf(fp,"\t\t %s > %s\n",hexbuf,ascbuf);

}
Пример #30
0
static int execute_le_test_end(char *szPort)
{
    ComHelper SerialPort;

    if (!SerialPort.OpenPort(szPort))
	{
        printf("Open %s port Failed\n", szPort);
		return 0;
	}

    UINT8 hci_le_test_end[] = {0x01, 0x1f, 0x20, 0x00};
    UINT8 hci_le_test_end_cmd_complete_event[] = {0x04, 0x0e, 0x06, 0x01, 0x1f, 0x20, 0x00};

    printf ("Sending HCI Command:\n");
    HexDump(hci_le_test_end, sizeof(hci_le_test_end));

    // write HCI reset
    SerialPort.Write(hci_le_test_end, sizeof(hci_le_test_end));

    // read HCI response header
    DWORD dwRead = SerialPort.Read((LPBYTE)&in_buffer[0], 3);

    // read HCI response payload
    if (dwRead == 3 && in_buffer[2] > 0)
        dwRead += SerialPort.Read((LPBYTE)&in_buffer[3], in_buffer[2]);

    printf ("Received HCI Event:\n");
    HexDump(in_buffer, dwRead);
    if ((dwRead > sizeof(hci_le_test_end_cmd_complete_event))
     && (memcmp(in_buffer, hci_le_test_end_cmd_complete_event, sizeof(hci_le_test_end_cmd_complete_event)) == 0))
    {
        printf("Success num_packets_received %d\n", in_buffer[7] + (in_buffer[8] << 8));
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}