Here is a snippet of code I have to handle smooth scrolling. here is the output of the NSLog:
2010-06-21 16:04:10.524 PDFViewWXOSX[80161:a0f] first error: -9870
2010-06-21 16:04:10.525 PDFViewWXOSX[80161:a0f] second error: 0
2010-06-21 16:04:10.552 PDFViewWXOSX[80161:a0f] first error: 0
2010-06-21 16:04:10.553 PDFViewWXOSX[80161:a0f] second error: 0
2010-06-21 16:04:10.582 PDFViewWXOSX[80161:a0f] first error: 0
2010-06-21 16:04:10.582 PDFViewWXOSX[80161:a0f] second error: 0
2010-06-21 16:04:10.588 PDFViewWXOSX[80161:a0f] first error: -9870
2010-06-21 16:04:10.589 PDFViewWXOSX[80161:a0f] second error: 0
2010-06-21 16:04:10.652 PDFViewWXOSX[80161:a0f] first error: 0
2010-06-21 16:04:10.652 PDFViewWXOSX[80161:a0f] second error: 0
2010-06-21 16:04:10.723 PDFViewWXOSX[80161:a0f] first error: 0
2010-06-21 16:04:10.723 PDFViewWXOSX[80161:a0f] second error: 0
SInt32 scroll_delta_x = 0, scroll_delta_y = 0;
OSErr err = noErr;
err = GetEventParameter( cEvent, kEventParamMouseWheelSmoothHorizontalDelta,
typeSInt32, NULL, sizeof(scroll_delta_x), NULL,
&scroll_delta_x);
NSLog(#"first error: %d", err);
if (err == noErr) {
deltaX = scroll_delta_x;
}
err = noErr;
err = GetEventParameter( cEvent, kEventParamMouseWheelSmoothVerticalDelta,
typeSInt32, NULL, sizeof(scroll_delta_y), NULL,
&scroll_delta_y);
NSLog(#"second error: %d", err);
if (err == noErr) {
deltaY = scroll_delta_y;
}
I couldn't find any information on error -9870. What is going on?
Error -9870 is eventParameterNotFoundErr, declared in CarbonEventsCore.h. The header comments on those event parameters say that you should be prepared for the possibility that they are not present.
Related
I am doing an assignment and this error pops up
File "/mnt/c/Users/nasos/Desktop/Pierce/Racecar/racecar-racecar-pierce/labs/lab2/../../library/racecar_utils.py", line 594, in get_contour_area
return cv.contourArea(contour)
cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgproc/src/shapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'contourArea'
What do I do?
when executing this:
err = setuid(0);
if (err < 0) {
fprintf(stderr, "return value: %d \n", err);
fprintf(stderr, "error code: %d \n", errno);
}
I am getting this output:
return value: -1
error code: 1
Error code 1 implies an EPERM error. Any ideas as to how should I fix it?
You cannot setuid() to root from a non-root user.
If you want to run your application as root, use Authorization Services, or sudo if it's a command-line tool.
SETUID(2) Man Pages
If the user is not the super user, or the uid specified is not the
real, effective ID, or saved ID,these functions return -1.
setuid(0); will work only from root(SU) user.
error code: 1
#define EPERM 1 /* Operation not permitted */
I had write my code to run ping pong parallel program. Below are my code:
#include <mpi.h>
#include <stdlib.h>
#include <stdio.h>
int main (int argc, char **argv){
//t0 Start Time
//t1 End Time
int size,rank,msgtag = 1;
double t0,t1,tmaster,tslave ;
MPI_Status status;
//initialize
int x;
//initialize MPI
if (MPI_Init(&argc, &argv) != MPI_SUCCESS) {
fprintf(stderr, "MPI initialization error\n");
return EXIT_FAILURE;
}
MPI_Comm_size(MPI_COMM_WORLD,&size);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
//communication between 2 nodes
///action process 0
if(rank == 0){
//start timer
//master process
t0 = MPI_Wtime();
MPI_Send(&x,1,MPI_INT,1,msgtag,MPI_COMM_WORLD);
//stop timer
t1 = MPI_Wtime();
//calculate elapsed time
tmaster = (t1 - t0);
MPI_Recv(&tslave,1,MPI_DOUBLE,1,msgtag,MPI_COMM_WORLD,&status);
printf("Master time: %g \n\n",tmaster);
printf("slave time: %g \n\n",tslave);
}else{
///action process 1
//receive message
t0 = MPI_Wtime();
MPI_Recv(&x,1,MPI_INT,0,msgtag,MPI_COMM_WORLD,&status);
t1 = MPI_Wtime();
tslave = (t1 - t0);
//Send message
MPI_Send(&tslave,1,MPI_DOUBLE,0,msgtag,MPI_COMM_WORLD);
}
MPI_Finalize();
}
I can run my code without any error or warning. However, when I try to debug it, it show me this fatal error:
job aborted:
rank:node:exit node:message:
0:localhost:-101:Fatal error in MPI_Send:invalid rank,error stack:
MPI_Send<172>:MPI_Send<buf=0x003FFBB4, count=1, MPI_INNT,dest=1, tag=1,MPI_COMM_WORLD> failed
MPI_Send<97>.; invalid rank has value 1 but must be non negative and less then 1
Anyone know how to fix this fatal error?
It looks like you're not running your code correctly (only launching one process). Make sure your mpiexec call passes a value greater than 0 for the -n flag. For example:
mpiexec -n 2 ./pingpong
You haven't declared value of x?
What is the value of x?
Run it with 2 processes.
I am writing a Cocoa application which uses bluetooth. I am trying to connect to a bluetooth device but it fails.
IOBluetoothDevice *btDevice;
// I do search and find the device
btDevice = ;//device found
//btDevice is not nil
IOReturn status = [btDevice openConnection];
if (status != kIOReturnSuccess) {
NSLog( #"Error - failed to connect. %d", status );
}
And I get the device when searches, but openConnection method fails. And NSLog prints
Error = failed to connect. 4
Now what this error code indicates?
I looked at IOKit.framework/IOReturn.h file and it shows many error codes
#define kIOReturnError iokit_common_err(0x2bc) // general error
#define kIOReturnNoMemory iokit_common_err(0x2bd) // can't allocate memory
#define kIOReturnNoResources iokit_common_err(0x2be) // resource shortage
#define kIOReturnIPCError iokit_common_err(0x2bf) // error during IPC
#define kIOReturnNoDevice iokit_common_err(0x2c0) // no such device
.......
//And many more
And I wrote a function to identify what is error code 4
- (void)logError:(OSStatus)status{
if (status == kIOReturnError) {
NSLog(#"kIOReturnError");
}else if(status == kIOReturnNoMemory){
NSLog(#"kIOReturnNoMemory");
}else if(status == kIOReturnNoResources){
NSLog(#"kIOReturnNoResources");
}else if(status == kIOReturnIPCError){
NSLog(#"kIOReturnIPCError");
}else if(status == kIOReturnNoDevice){
......
......
}else{
NSLog(#"No price for you");
}
}
And it prints
No price for you
What does error code 4 imply? Also is there any easier way to identify error reason from OSStatus error codes?
[IOBluetoothDevice openConnection] returns an IOReturn code (which is a I/O Kit specific error number) while your logError: method tests for OSStatus codes.
OSStatus is not the same as IOReturn.
Apple has a Technical Q&A that explains the macros to lookup I/O Kit errors.
http://developer.apple.com/library/mac/#qa/qa1075/_index.html
In your case it seems to be a Mach error (that's probably the 0x4 hi bits of the error that show up as decimal 4 in your log line).
I think the 4 response is actually kBluetoothHCIErrorPageTimeout. The only code I've found that uses this is this: https://www.ida.liu.se/~TDDD63/projects/2013/mindstorms/Installation/Mac/lightblue-0.4-master/src/mac/_bluetoothsockets.py
First some simple code snippet:
m_hProcessHandle = ::OpenProcess((PROCESS_QUERY_INFORMATION | PROCESS_CREATE_THREAD | PROCESS_DUP_HANDLE | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION), FALSE, m_dwProcessIdentifier);
if (NULL != m_hProcessHandle)
{
if (FALSE != ::OpenProcessToken(m_hProcessHandle, (TOKEN_QUERY | TOKEN_IMPERSONATE | TOKEN_DUPLICATE), &m_hImpersonizationToken))
{
wchar_t wszFullExecutableFileName[MAX_PATH];
if (0 == ::GetModuleBaseName(m_hProcessHandle, NULL, wszFullExecutableFileName, (sizeof(wszFullExecutableFileName)/sizeof(wchar_t))))
{
__DebugMessage(L"GetModuleBaseName() failed with GetLastError() = %d", ::GetLastError());
}
else
{
if (0 == ::GetModuleFileNameEx(m_hProcessHandle, NULL, wszFullExecutableFileName, (sizeof(wszFullExecutableFileName)/sizeof(wchar_t))))
{
__DebugMessage(L"GetModuleFileNameEx() failed with GetLastError() = %d", ::GetLastError());
}
else
{
m_strFullFileName = wszFullExecutableFileName;
}
}
}
}
The OpenProcess() returns a valid handle as does the OpenProcessToken(), but when I call the subsequent GetModuleBaseName() and GetModuleFileNameEx() functions, I get GetLastError() = 6 (The handle is invalid). I am running that code as admin on Windows 7. What gives?
cheers,
GumbyTheBorg
You must run this program as administrator in order for it to work correctly. I just tested it working and GetLastError() = 0 after each line, which means there were no problems.