void deviceMotionSimulationHandleRawData(char commandHeader, InputStream* inputStream, OutputStream* outputStream) { if (commandHeader == COMMAND_MOTION_SIMULATION_GET) { // send acknowledge ackCommand(outputStream, MOTION_SIMULATION_DEVICE_HEADER, COMMAND_MOTION_SIMULATION_GET); MotionSimulationParameter* motionSimulationParameter = getMotionSimulationParameter(); appendHex(outputStream, motionSimulationParameter->simulateMotors); appendHex(outputStream, motionSimulationParameter->simulateCoders); appendHex(outputStream, motionSimulationParameter->simulateRobotPosition); } else if (commandHeader == COMMAND_MOTION_SIMULATION_SET) { // send acknowledge ackCommand(outputStream, MOTION_SIMULATION_DEVICE_HEADER, COMMAND_MOTION_SIMULATION_SET); bool simulateMotors = readHex(inputStream); bool simulateCoders = readHex(inputStream); bool simulateRobotPosition = readHex(inputStream); MotionSimulationParameter* motionSimulationParameter = getMotionSimulationParameter(); motionSimulationParameter->simulateMotors = simulateMotors; motionSimulationParameter->simulateCoders = simulateCoders; motionSimulationParameter->simulateRobotPosition = simulateRobotPosition; } }
void utilityOskLog(char *buffer, const SyscallInfo *syscallInfo, u32 param) { char *s = buffer; if (syscallInfo->nid != 0xF6269B82 && syscallInfo->nid != 0x3DFAEBA9) { return; } if (syscallInfo->nid == 0xF6269B82) { utilityOskParams = (void *) param; } int oskDataAddr = _lw((int) utilityOskParams + 52); if (oskDataAddr != 0) { s = append(s, "inputMode="); s = appendHex(s, _lw(oskDataAddr + 0), 0); s = append(s, ", inputAttr="); s = appendHex(s, _lw(oskDataAddr + 4), 0); } if (syscallInfo->nid == 0x3DFAEBA9) { s = append(s, ", result="); s = appendHex(s, _lw((int) utilityOskParams + 28), 8); } s = append(s, "\n"); writeLog(buffer, s - buffer); s = buffer; printLogMem("Params ", (int) utilityOskParams, _lw((int) utilityOskParams + 0)); }
void CollationRegressionTest::assertEqual(CollationElementIterator &i1, CollationElementIterator &i2) { int32_t c1, c2, count = 0; UErrorCode status = U_ZERO_ERROR; do { c1 = i1.next(status); c2 = i2.next(status); if (c1 != c2) { UnicodeString msg, msg1(" "); msg += msg1 + count; msg += ": strength(0x"; appendHex(c1, 8, msg); msg += ") != strength(0x"; appendHex(c2, 8, msg); msg += ")"; errln(msg); break; } count += 1; } while (c1 != CollationElementIterator::NULLORDER); }
void printLogHH(const char *s1, int hex1, const char *s2, int hex2, const char *s3) { char buffer[200]; char *s = buffer; s = append(s, s1); s = appendHex(s, hex1, 0); s = append(s, s2); s = appendHex(s, hex2, 0); s = append(s, s3); writeLog(buffer, s - buffer); }
static int interruptSend(deviceInfo *info, void *buffer, int bufSize, int timeout) { usbDevice *handle = handleFromInfoPtr(info); int retval, amount; message(LOG_DEBUG2, "o"); appendHex(LOG_DEBUG2, buffer, bufSize); setError(handle, NULL, LIBUSB_SUCCESS); if (handle->info.stopped) return -(errno = ENXIO); /* NOTE: when firmware 0205 hangs during a send this call NEVER times out meaning that we have NO way to recover in the daemon so there's no point in trying to handle it. */ retval = libusb_interrupt_transfer(handle->device, handle->epOut->bEndpointAddress, buffer, bufSize, &amount, timeout); if (retval < 0) { setError(handle, "Failed to write (interrupt end point)", retval); return retval; } return amount; }
std::string UUID::toString() const { std::string result; result.reserve(36); appendHex(result, _timeLow); result += '-'; appendHex(result, _timeMid); result += '-'; appendHex(result, _timeHiAndVersion); result += '-'; appendHex(result, _clockSeq); result += '-'; for (int i = 0; i < sizeof(_node); ++i) appendHex(result, _node[i]); return result; }
void utilitySavedataLog(char *buffer, const SyscallInfo *syscallInfo, u32 param) { char *s = buffer; if (syscallInfo->nid == 0x50C4CD57) { utilitySavedataParams = (void *) param; } int mode = _lw((int) utilitySavedataParams + 48); s = append(s, "mode="); s = appendInt(s, mode, 0); s = append(s, ", gameName="); s = append(s, utilitySavedataParams + 60); s = append(s, ", saveName="); s = append(s, utilitySavedataParams + 76); s = append(s, ", fileName="); s = append(s, utilitySavedataParams + 100); if (syscallInfo->nid == 0x9790B33C) { s = append(s, ", result="); s = appendHex(s, _lw((int) utilitySavedataParams + 28), 8); } s = append(s, "\n"); writeLog(buffer, s - buffer); s = buffer; printLogMem("Data ", _lw((int) utilitySavedataParams + 116), 16); printLogMem("Params ", (int) utilitySavedataParams, _lw((int) utilitySavedataParams + 0)); }
BOOL motionDriverBSplineAbsolute(float x, float y, float angle, float dist0, float dist1, int accelerationFactor, int speedFactor) { OutputStream* outputStream = getDriverRequestOutputStream(); append(outputStream, COMMAND_MOTION_SPLINE_ABSOLUTE); appendHex4(outputStream, x); appendSeparator(outputStream); appendHex4(outputStream, y); appendSeparator(outputStream); appendHex4(outputStream, angle); appendSeparator(outputStream); appendHex2(outputStream, dist0); appendSeparator(outputStream); appendHex2(outputStream, dist1); appendSeparator(outputStream); appendHex(outputStream, accelerationFactor); appendHex(outputStream, speedFactor); BOOL result = transmitFromDriverRequestBuffer(); return result; }
void Strpack::pack(float f) { int i; union { uint8_t b[4]; uint32_t ui32; float f; } reg; reg.f = f; for (i = 3; i >= 0; i--) appendHex(reg.b[i]); }
UnicodeString &CollationIteratorTest::orderString(CollationElementIterator &iter, UnicodeString &target) { int32_t order; UErrorCode status = U_ZERO_ERROR; while ((order = iter.next(status)) != CollationElementIterator::NULLORDER) { target += "0x"; appendHex(order, 8, target); target += " "; } return target; }
// send incoming CAN message to current bridge session, if any static void canToBridge (const CANRxFrame* rxMsg) { if (currConn != 0) { char buf [30]; uint32_t id = rxMsg->EID; if (!rxMsg->IDE) id &= 0x7FF; chsnprintf(buf, sizeof buf, "S%x#", id); char* p = buf + strlen(buf); int i; for (i = 0; i < rxMsg->DLC; ++i) p = appendHex(p, rxMsg->data8[i]); strcpy(p, "\r\n"); netconn_write(currConn, buf, strlen(buf), NETCONN_COPY); } }
void printLogMem(const char *s1, int addr, int length) { int i, j; int lineStart; char buffer[100]; char *s = buffer; s = append(s, s1); s = appendHex(s, addr, 8); s = append(s, ":\n"); if (addr != 0) { lineStart = 0; for (i = 0; i < length; i += 4) { if (i > 0) { if ((i % 16) == 0) { s = append(s, " >"); for (j = lineStart; j < i; j++) { char c = _lb(addr + j); if (c < ' ' || c > '~') { c = '.'; } *s++ = c; } s = append(s, "<\n"); writeLog(buffer, s - buffer); s = buffer; lineStart = i; } else { s = append(s, ", "); } } s = appendHex(s, _lw(addr + i), 8); } } s = append(s, "\n"); writeLog(buffer, s - buffer); }
// Replace nonprintable characters with unicode escapes UnicodeString escape(const UnicodeString &source) { int32_t i; UnicodeString target; target += "\""; for (i=0; i<source.length(); ++i) { UChar ch = source[i]; if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) { target += "\\u"; appendHex(ch, 4, target); } else { target += ch; } } target += "\""; return target; }
// Produce a printable representation of a CollationKey UnicodeString &IntlTestCollator::prettify(const CollationKey &source, UnicodeString &target) { int32_t i, byteCount; const uint8_t *bytes = source.getByteArray(byteCount); target.remove(); target += "["; for (i = 0; i < byteCount; i += 1) { if (i != 0) { target += " "; } appendHex(bytes[i], 2, target); } target += "]"; return target; }
static int interruptRecv(deviceInfo *info, void *buffer, int bufSize, int timeout) { usbDevice *handle = handleFromInfoPtr(info); int retval, amount; if (handle->info.stopped) return -(errno = ENXIO); retval = libusb_interrupt_transfer(handle->device, handle->epIn->bEndpointAddress, buffer, bufSize, &amount, timeout); if (retval < 0) { setError(handle, "Failed to read (interrupt end point)", retval); return retval; } message(LOG_DEBUG2, "i"); appendHex(LOG_DEBUG2, buffer, amount); return amount; }
char *syscallLogMem(char *buffer, char *s, int addr, int length) { int i, j; int lineStart; int value; s = appendHex(s, addr, 8); if (addr != 0) { *s++ = ':'; *s++ = '\n'; writeLog(buffer, s - buffer); s = buffer; lineStart = 0; for (i = 0; i < length; i++) { if (i > 0) { if ((i % 16) == 0) { s = append(s, " >"); for (j = lineStart; j < i; j++) { char c = _lb(addr + j); if (c < ' ' || c > '~') { c = '.'; } *s++ = c; } s = append(s, "<\n"); writeLog(buffer, s - buffer); s = buffer; lineStart = i; } else { *s++ = ' '; } } value = _lb(addr + i); *s++ = hexDigits[value >> 4]; *s++ = hexDigits[value & 0x0F]; } }
void utilityMsgLog(char *buffer, const SyscallInfo *syscallInfo, u32 param) { char *s = buffer; if (syscallInfo->nid != 0x2AD8E239 && syscallInfo->nid != 0x67AF3428) { return; } if (syscallInfo->nid == 0x2AD8E239) { utilityMsgParams = (void *) param; } s = append(s, "result="); s = appendHex(s, _lw((int) utilityMsgParams + 48), 0); s = append(s, ", mode="); s = appendHex(s, _lw((int) utilityMsgParams + 52), 0); s = append(s, ", errorValue="); s = appendHex(s, _lw((int) utilityMsgParams + 56), 0); s = append(s, ", options="); s = appendHex(s, _lw((int) utilityMsgParams + 572), 0); s = append(s, ", buttonPressed="); s = appendHex(s, _lw((int) utilityMsgParams + 576), 0); if (syscallInfo->nid == 0x67AF3428) { s = append(s, ", result="); s = appendHex(s, _lw((int) utilityMsgParams + 28), 8); } s = append(s, "\n"); writeLog(buffer, s - buffer); #if 0 s = buffer; s = append(s, "message="); s = append(s, utilityMsgParams + 60); s = append(s, "\n"); writeLog(buffer, s - buffer); printLogMem("Params ", (int) utilityMsgParams, _lw((int) utilityMsgParams + 0)); #endif }
void syscallLog(const SyscallInfo *syscallInfo, const u32 *parameters, u64 result, u32 ra, const char *prefix) { char buffer[300]; char *s = buffer; int i, j, k; int length; int lineStart; // Don't log out own sceIoWrites. if (syscallInfo->nid == 0x42EC03AC && parameters[0] == commonInfo->logFd) { return; } if (logTimestamp) { pspTime time; if (sceRtcGetCurrentClockLocalTime(&time) == 0) { s = appendInt(s, time.hour, 2); *s++ = ':'; s = appendInt(s, time.minutes, 2); *s++ = ':'; s = appendInt(s, time.seconds, 2); *s++ = '.'; s = appendInt(s, time.microseconds, 6); *s++ = ' '; } } if (logThreadName) { SceKernelThreadInfo currentThreadInfo; currentThreadInfo.size = sizeof(currentThreadInfo); currentThreadInfo.name[0] = '\0'; sceKernelReferThreadStatus(0, ¤tThreadInfo); s = append(s, currentThreadInfo.name); *s++ = ' '; *s++ = '-'; *s++ = ' '; } if (logRa) { s = appendHex(s, ra, 0); *s++ = ' '; } s = append(s, prefix); s = append(s, syscallInfo->name); int types = syscallInfo->paramTypes; for (i = 0; i < syscallInfo->numParams; i++, types >>= 4) { if (i > 0) { *s++ = ','; } *s++ = ' '; int parameter = parameters[i]; switch (types & 0xF) { case TYPE_HEX32: s = appendHex(s, parameter, 0); break; case TYPE_INT32: s = appendInt(s, parameter, 0); break; case TYPE_STRING: s = appendHex(s, parameter, 8); if (parameter != 0) { *s++ = '('; *s++ = '\''; s = append(s, (char *) parameter); *s++ = '\''; *s++ = ')'; } break; case TYPE_POINTER32: s = appendHex(s, parameter, 8); if (parameter != 0) { *s++ = '('; s = appendHex(s, _lw(parameter), 0); *s++ = ')'; } break; case TYPE_POINTER64: s = appendHex(s, parameter, 8); if (parameter != 0) { *s++ = '('; s = appendHex(s, _lw(parameter), 8); *s++ = ' '; s = appendHex(s, _lw(parameter + 4), 8); *s++ = ')'; } break; case TYPE_VARSTRUCT: s = appendHex(s, parameter, 8); if (parameter != 0) { *s++ = ':'; *s++ = '\n'; writeLog(buffer, s - buffer); s = buffer; length = _lw(parameter); lineStart = 0; for (j = 0; j < length; j += 4) { if (j > 0) { if ((j % 16) == 0) { s = append(s, " >"); for (k = lineStart; k < j; k++) { char c = _lb(parameter + k); if (c < ' ' || c > '~') { c = '.'; } *s++ = c; } s = append(s, "<\n"); writeLog(buffer, s - buffer); s = buffer; lineStart = j; } else { *s++ = ','; *s++ = ' '; } } s = appendHex(s, _lw(parameter + j), 8); } } break; case TYPE_FIXSTRUCT: s = appendHex(s, parameter, 8); if (parameter != 0) { *s++ = ':'; *s++ = '\n'; writeLog(buffer, s - buffer); s = buffer; length = FIXSTRUCT_SIZE; lineStart = 0; for (j = 0; j < length; j += 4) { if (j > 0) { if ((j % 16) == 0) { s = append(s, " >"); for (k = lineStart; k < j; k++) { char c = _lb(parameter + k); if (c < ' ' || c > '~') { c = '.'; } *s++ = c; } s = append(s, "<\n"); writeLog(buffer, s - buffer); s = buffer; lineStart = j; } else { *s++ = ','; *s++ = ' '; } } s = appendHex(s, _lw(parameter + j), 8); } } break; } } *s++ = ' '; *s++ = '='; *s++ = ' '; s = appendHex(s, (int) result, 0); #if DEBUG_MUTEX s = mutexLog(s, syscallInfo, parameters, result); #endif *s++ = '\n'; writeLog(buffer, s - buffer); #if DEBUG_UTILITY_SAVEDATA utilitySavedataLog(buffer, syscallInfo, parameters[0]); #endif }
void IntlTestCollator::backAndForth(CollationElementIterator &iter) { // Run through the iterator forwards and stick it into an array int32_t orderLength = 0; LocalArray<Order> orders(getOrders(iter, orderLength)); UErrorCode status = U_ZERO_ERROR; // Now go through it backwards and make sure we get the same values int32_t index = orderLength; int32_t o; // reset the iterator iter.reset(); while ((o = iter.previous(status)) != CollationElementIterator::NULLORDER) { /*int32_t offset = */iter.getOffset(); if (index == 0) { if(o == 0) { continue; } else { // this is an error, orders exhausted but there are non-ignorable CEs from // going backwards errln("Backward iteration returned a non ignorable after orders are exhausted"); break; } } index -= 1; if (o != orders[index].order) { if (o == 0) index += 1; else { while (index > 0 && orders[--index].order == 0) { // nothing... } if (o != orders[index].order) { errln("Mismatched order at index %d: 0x%0:8X vs. 0x%0:8X", index, orders[index].order, o); //break; return; } } } #if TEST_OFFSETS if (offset != orders[index].offset) { errln("Mismatched offset at index %d: %d vs. %d", index, orders[index].offset, offset); //break; return; } #endif } while (index != 0 && orders[index - 1].order == 0) { index --; } if (index != 0) { UnicodeString msg("Didn't get back to beginning - index is "); errln(msg + index); iter.reset(); err("next: "); while ((o = iter.next(status)) != CollationElementIterator::NULLORDER) { UnicodeString hexString("0x"); appendHex(o, 8, hexString); hexString += " "; err(hexString); } errln(""); err("prev: "); while ((o = iter.previous(status)) != CollationElementIterator::NULLORDER) { UnicodeString hexString("0x"); appendHex(o, 8, hexString); hexString += " "; err(hexString); } errln(""); } }
void utilitySavedataLog(char *buffer, const SyscallInfo *syscallInfo, u32 param) { char *s = buffer; int fd; if (syscallInfo->nid != 0x50C4CD57 && syscallInfo->nid != 0x9790B33C) { return; } if (syscallInfo->nid == 0x50C4CD57) { utilitySavedataParams = (void *) param; } if (utilitySavedataParams == NULL) { return; } int mode = _lw((int) utilitySavedataParams + 48); s = append(s, "mode="); s = appendInt(s, mode, 0); s = append(s, ", gameName="); s = append(s, utilitySavedataParams + 60); s = append(s, ", saveName="); s = append(s, utilitySavedataParams + 76); s = append(s, ", fileName="); s = append(s, utilitySavedataParams + 100); if (syscallInfo->nid == 0x9790B33C) { s = append(s, ", result="); s = appendHex(s, _lw((int) utilitySavedataParams + 28), 8); } s = append(s, "\n"); writeLog(buffer, s - buffer); s = buffer; printLogMem("Data ", _lw((int) utilitySavedataParams + 116), 16); int fileListAddr = _lw((int) utilitySavedataParams + 1528); if (fileListAddr != 0 && mode == 12) { // MODE_FILES printLogMem("FileList ", fileListAddr, 36); if (syscallInfo->nid == 0x9790B33C) { // sceUtilitySavedataShutdownStart int saveFileSecureNumEntries = _lw(fileListAddr + 12); int saveFileNumEntries = _lw(fileListAddr + 16); int systemFileNumEntries = _lw(fileListAddr + 20); int saveFileSecureEntriesAddr = _lw(fileListAddr + 24); int saveFileEntriesAddr = _lw(fileListAddr + 28); int systemEntriesAddr = _lw(fileListAddr + 32); printLogMem("SecureEntries ", saveFileSecureEntriesAddr, saveFileSecureNumEntries * 80); printLogMem("NormalEntries ", saveFileEntriesAddr, saveFileNumEntries * 80); printLogMem("SystemEntries ", systemEntriesAddr, systemFileNumEntries * 80); } } printLogMem("Params ", (int) utilitySavedataParams, _lw((int) utilitySavedataParams + 0)); if (syscallInfo->nid == 0x9790B33C) { fd = ioOpen("ms0:/SavedataStruct.bin", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777); ioWrite(fd, utilitySavedataParams, _lw((int) utilitySavedataParams + 0)); ioClose(fd); fd = ioOpen("ms0:/SavedataData.bin", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777); ioWrite(fd, (void *) _lw((int) utilitySavedataParams + 116), _lw((int) utilitySavedataParams + 124)); ioClose(fd); } }