diff --git a/MacMiner/AppDelegate.m b/MacMiner/AppDelegate.m index 3a644d1..8c7ba77 100644 --- a/MacMiner/AppDelegate.m +++ b/MacMiner/AppDelegate.m @@ -35,7 +35,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification NSString *hideVersion = [prefs objectForKey:@"hideVersion"]; - if ([hideVersion isEqualToString:@"1510"]) { + if ([hideVersion isEqualToString:@"1511"]) { [self.releaseNotes orderOut:nil]; } @@ -547,7 +547,7 @@ - (IBAction)hideVersionStuff:(id)sender { NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; - [prefs setObject:@"1510" forKey:@"hideVersion"]; + [prefs setObject:@"1511" forKey:@"hideVersion"]; [prefs synchronize]; diff --git a/MacMiner/MacMiner-Info.plist b/MacMiner/MacMiner-Info.plist index d9b6014..0512f02 100644 --- a/MacMiner/MacMiner-Info.plist +++ b/MacMiner/MacMiner-Info.plist @@ -19,11 +19,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.5.10b + 1.5.11 CFBundleSignature ???? CFBundleVersion - 1510b + 1511 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/MacMiner/asicMiner.m b/MacMiner/asicMiner.m index 51701df..1c08de0 100644 --- a/MacMiner/asicMiner.m +++ b/MacMiner/asicMiner.m @@ -23,9 +23,12 @@ - (id)initWithCoder:(NSCoder *)aDecoder // NSLog(@"startup"); // AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; + self.asicAPIOutput.delegate = self; + + self.acceptLabel.tag = 1; - self.apiDataArray = [[NSMutableArray alloc] init]; + self.apiDataArray = [[NSMutableArray alloc] init]; [self startToggling]; @@ -38,115 +41,6 @@ - (id)initWithCoder:(NSCoder *)aDecoder self.minerAddressesArray = [[NSMutableArray alloc] init]; // self.minerAddressesArray = [self.prefs objectForKey:@"ipAddress"]; - if ([[self.prefs objectForKey:@"startAsic"] isEqualToString:@"start"]) { - - - [self.asicStartButton setTitle:@"Stop"]; - self.asicStartButton.tag = 0; -// self.asicAPIOutput.string = @""; -// [self.asicAPIOutput delete:nil]; - - - - // If the task is still sitting around from the last run, release it - if (asicTask!=nil) { - asicTask = nil; - } - - - - - - - - self.noGPU = [self.prefs stringForKey:@"disableASICGPU"]; - self.debugOutputOn = [self.prefs stringForKey:@"debugASICOutput"]; - self.quietOutputOn = [self.prefs stringForKey:@"quietASICOutput"]; - self.bonusOptions = [self.prefs stringForKey:@"asicOptionsValue"]; - NSString *cpuThreads = [self.prefs stringForKey:@"cpuASICThreads"]; - - - - NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: @"-T", @"--api-listen", @"--api-allow", @"W:0/0", nil]; - if ([self.bonusOptions isNotEqualTo:@""]) { - NSArray *deviceItems = [self.bonusOptions componentsSeparatedByString:@" "]; - - [launchArray addObjectsFromArray:deviceItems]; - } - - if ([cpuThreads isNotEqualTo:nil]) { - [launchArray addObject:@"-t"]; - [launchArray addObject:cpuThreads]; - } - else { - [launchArray addObject:@"-t"]; - [launchArray addObject:@"0"]; - } - - if ([self.debugOutputOn isNotEqualTo:nil]) { - [launchArray addObject:self.debugOutputOn]; - } - if ([self.quietOutputOn isNotEqualTo:nil]) { - [launchArray addObject:self.quietOutputOn]; - } - - if (self.bigpicEnable.state == NSOnState) { - [launchArray addObject:@"-S"]; - [launchArray addObject:@"bigpic:all"]; - } - if (self.antminerEnable.state == NSOnState) { - [launchArray addObject:@"-S"]; - [launchArray addObject:@"antminer:all"]; - } - if (self.bflEnable.state == NSOnState) { - [launchArray addObject:@"-S"]; - [launchArray addObject:@"bfl:all"]; - } - if (self.bitfuryEnable.state == NSOnState) { - [launchArray addObject:@"-S"]; - [launchArray addObject:@"bifury:all"]; - } - if (self.erupterEnable.state == NSOnState) { - [launchArray addObject:@"-S"]; - [launchArray addObject:@"erupter:all"]; - } - - - - if ([self.noGPU isNotEqualTo:nil]) { - [launchArray addObject:@"-S"]; - [launchArray addObject:@"opencl:auto"]; - } - - cpuThreads = nil; - - NSString *executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - NSString *userpath = [paths objectAtIndex:0]; - userpath = [userpath stringByAppendingPathComponent:executableName]; // The file will go in this directory - NSString *saveBTCConfigFilePath = [userpath stringByAppendingPathComponent:@"bfgurls.conf"]; - - [launchArray addObject:@"-c"]; - [launchArray addObject:saveBTCConfigFilePath]; - - - - NSString *bundlePath2 = [[NSBundle mainBundle] resourcePath]; - - NSString *bfgPath = [bundlePath2 stringByAppendingString:@"/bfgminer/bin/bfgminer"]; - - [self.asicOutputView setString:@""]; - - asicTask =[[TaskWrapper alloc] initWithCommandPath:bfgPath - arguments:launchArray - environment:nil - delegate:self]; - // kick off the process asynchronously - - [asicTask startTask]; - - - } } @@ -154,16 +48,6 @@ - (id)initWithCoder:(NSCoder *)aDecoder return self; } -/* - - (void)alertDidEnd:(NSAlert *)pipAlert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { - if (returnCode == NSAlertFirstButtonReturn) { - NSLog(@"install pip"); - } - if (returnCode == NSAlertSecondButtonReturn) { - NSLog(@"quit"); - } - } - */ @@ -252,7 +136,7 @@ - (IBAction)start:(id)sender - NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: @"-T", @"--api-listen", @"--api-allow", @"W:0/0", nil]; + NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: @"-T", @"--api-listen", @"--api-allow", @"R:0/0", nil]; if ([self.bonusOptions isNotEqualTo:@""]) { NSArray *deviceItems = [self.bonusOptions componentsSeparatedByString:@" "]; @@ -401,7 +285,7 @@ - (void)toggleLoopTimerFired:(NSTimer*)timer - NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: @"-T", @"--api-listen", @"--api-allow", @"W:0/0", nil]; + NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: @"-T", @"--api-listen", @"--api-allow", @"R:0/0", nil]; if ([self.bonusOptions isNotEqualTo:@""]) { NSArray *deviceItems = [self.bonusOptions componentsSeparatedByString:@" "]; @@ -924,6 +808,7 @@ - (void)taskTwoWrapper:(taskTwoWrapper *)taskTwoWrapper didProduceOutput:(NSStri // self.asicAPIOutput.string = @""; [self.asicAPIOutput delete:nil]; + [self.asicAPIOutput didChangeText]; self.asicAPIOutput.string = output; @@ -1232,6 +1117,9 @@ - (IBAction)clearNetworkedMinerApply:(id)sender // control of the UI. -(void)awakeFromNib { + + + findRunning=NO; findTwoRunning=NO; @@ -1247,6 +1135,119 @@ -(void)awakeFromNib if (asicOptionsString != nil) { [self.asicOptionsView setStringValue:asicOptionsString]; } + + if ([[self.prefs objectForKey:@"startAsic"] isEqualToString:@"start"]) { + + [self.asicWindow orderFront:nil]; + + + [self.asicStartButton setTitle:@"Stop"]; + self.asicStartButton.tag = 0; + // self.asicAPIOutput.string = @""; + // [self.asicAPIOutput delete:nil]; + + + + // If the task is still sitting around from the last run, release it + if (asicTask!=nil) { + asicTask = nil; + } + + + + + + + + self.noGPU = [self.prefs stringForKey:@"disableASICGPU"]; + self.debugOutputOn = [self.prefs stringForKey:@"debugASICOutput"]; + self.quietOutputOn = [self.prefs stringForKey:@"quietASICOutput"]; + self.bonusOptions = [self.prefs stringForKey:@"asicOptionsValue"]; + NSString *cpuThreads = [self.prefs stringForKey:@"cpuASICThreads"]; + + + + NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: @"-T", @"--api-listen", @"--api-allow", @"R:0/0", nil]; + if ([self.bonusOptions isNotEqualTo:@""]) { + NSArray *deviceItems = [self.bonusOptions componentsSeparatedByString:@" "]; + + [launchArray addObjectsFromArray:deviceItems]; + } + + if ([cpuThreads isNotEqualTo:nil]) { + [launchArray addObject:@"-t"]; + [launchArray addObject:cpuThreads]; + } + else { + [launchArray addObject:@"-t"]; + [launchArray addObject:@"0"]; + } + + if ([self.debugOutputOn isNotEqualTo:nil]) { + [launchArray addObject:self.debugOutputOn]; + } + if ([self.quietOutputOn isNotEqualTo:nil]) { + [launchArray addObject:self.quietOutputOn]; + } + + if (self.bigpicEnable.state == NSOnState) { + [launchArray addObject:@"-S"]; + [launchArray addObject:@"bigpic:all"]; + } + if (self.antminerEnable.state == NSOnState) { + [launchArray addObject:@"-S"]; + [launchArray addObject:@"antminer:all"]; + } + if (self.bflEnable.state == NSOnState) { + [launchArray addObject:@"-S"]; + [launchArray addObject:@"bfl:all"]; + } + if (self.bitfuryEnable.state == NSOnState) { + [launchArray addObject:@"-S"]; + [launchArray addObject:@"bifury:all"]; + } + if (self.erupterEnable.state == NSOnState) { + [launchArray addObject:@"-S"]; + [launchArray addObject:@"erupter:all"]; + } + + + + if ([self.noGPU isNotEqualTo:nil]) { + [launchArray addObject:@"-S"]; + [launchArray addObject:@"opencl:auto"]; + } + + cpuThreads = nil; + + NSString *executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + NSString *userpath = [paths objectAtIndex:0]; + userpath = [userpath stringByAppendingPathComponent:executableName]; // The file will go in this directory + NSString *saveBTCConfigFilePath = [userpath stringByAppendingPathComponent:@"bfgurls.conf"]; + + [launchArray addObject:@"-c"]; + [launchArray addObject:saveBTCConfigFilePath]; + + + + NSString *bundlePath2 = [[NSBundle mainBundle] resourcePath]; + + NSString *bfgPath = [bundlePath2 stringByAppendingString:@"/bfgminer/bin/bfgminer"]; + + [self.asicOutputView setString:@""]; + + asicTask =[[TaskWrapper alloc] initWithCommandPath:bfgPath + arguments:launchArray + environment:nil + delegate:self]; + // kick off the process asynchronously + + [asicTask startTask]; + + + } + } @@ -1260,10 +1261,10 @@ - (IBAction)asicMinerToggle:(id)sender { [self.asicWindow orderFront:sender]; } } - + - (IBAction)optionsToggle:(id)sender { - + if ([self.asicOptionsWindow isVisible]) { [self.asicOptionsButton setState:NSOffState]; [self.asicOptionsWindow orderOut:sender]; diff --git a/MacMiner/bfgminerViewController.m b/MacMiner/bfgminerViewController.m index fb8fa13..8a63187 100644 --- a/MacMiner/bfgminerViewController.m +++ b/MacMiner/bfgminerViewController.m @@ -627,262 +627,6 @@ -(void)viewDidLoad self.bfgStatLabel.tag = 0; self.speedRead.tag = 0; bfgTask=nil; - - NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; - - [prefs synchronize]; - - if ([[prefs objectForKey:@"startBfg"] isEqualToString:@"start"]) { - [self.bfgStartButton setTitle:@"Stop"]; - // If the task is still sitting around from the last run, release it - if (bfgTask!=nil) { - bfgTask = nil; - } - - - AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; - appDelegate.bfgReading.stringValue = @""; - [appDelegate.bfgReadBack setHidden:NO]; - [appDelegate.bfgReading setHidden:NO]; - - - [[NSApp dockTile] display]; - - - // Let's allocate memory for and initialize a new TaskWrapper object, passing - // in ourselves as the controller for this TaskWrapper object, the path - // to the command-line tool, and the contents of the text field that - // displays what the user wants to search on - - // AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; - - - NSString *bundlePath2 = [[NSBundle mainBundle] resourcePath]; - - NSString *bfgPath = [bundlePath2 stringByAppendingString:@"/bfgminer/bin/bfgminer"]; - - - - [self.bfgOutputView setString:@""]; - NSString *startingText = @"Starting…"; - self.bfgStatLabel.stringValue = startingText; - startingText = nil; - - - NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: nil]; - - - - self.intensityValue = [prefs stringForKey:@"intenseValue"]; - self.worksizeValue = [prefs stringForKey:@"worksizeValue"]; - self.vectorValue = [prefs stringForKey:@"vectorValue"]; - self.noGPU = [prefs stringForKey:@"disableGPU"]; - self.onScrypt = [prefs stringForKey:@"useScrypt"]; - self.debugOutputOn = [prefs stringForKey:@"debugOutput"]; - self.quietOutputOn = [prefs stringForKey:@"quietOutput"]; - self.bonusOptions = [prefs stringForKey:@"bfgOptionsValue"]; - self.threadConc = [prefs stringForKey:@"bfgThreadConc"]; - self.shaders = [prefs stringForKey:@"bfgShaders"]; - self.lookupGap = [prefs stringForKey:@"bfgLookupGap"]; - NSString *cpuThreads = [prefs stringForKey:@"bfgCpuThreads"]; - - - [launchArray addObject:@"-T"]; - - if ([self.intensityValue isNotEqualTo:nil]) { - [launchArray addObject:@"-I"]; - [launchArray addObject:self.intensityValue]; - } - if ([self.worksizeValue isNotEqualTo:nil]) { - [launchArray addObject:@"-w"]; - [launchArray addObject:self.worksizeValue]; - } - if ([self.vectorValue isNotEqualTo:nil]) { - [launchArray addObject:@"-v"]; - [launchArray addObject:self.vectorValue]; - } - if (self.noGPU.length >= 1) { - [launchArray addObject:@"-S"]; - [launchArray addObject:@"opencl:auto"]; - } - if ([self.onScrypt isNotEqualTo:nil]) { - [launchArray addObject:self.onScrypt]; - } - if ([self.debugOutputOn isNotEqualTo:nil]) { - [launchArray addObject:self.debugOutputOn]; - } - if ([self.quietOutputOn isNotEqualTo:nil]) { - [launchArray addObject:self.quietOutputOn]; - } - if (self.threadConc.length >= 1) { - [launchArray addObject:@"--thread-concurrency"]; - [launchArray addObject:self.threadConc]; - } - if (self.shaders.length >= 1) { - [launchArray addObject:@"--shaders"]; - [launchArray addObject:self.shaders]; - } - if (self.lookupGap.length >= 1) { - [launchArray addObject:@"--lookup-gap"]; - [launchArray addObject:self.lookupGap]; - } - if (cpuThreads.length >= 1) { - [launchArray addObject:@"-t"]; - [launchArray addObject:cpuThreads]; - } - else { - [launchArray addObject:@"-t"]; - [launchArray addObject:@"0"]; - } - - self.executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; - self.paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - self.userpath = [self.paths objectAtIndex:0]; - self.userpath2 = [self.userpath stringByAppendingPathComponent:self.executableName]; // The file will go in this directory - self.saveBTCConfigFilePath = [self.userpath2 stringByAppendingPathComponent:@"bfgurls.conf"]; - self.saveLTCConfigFilePath = [self.userpath2 stringByAppendingPathComponent:@"ltcurls.conf"]; - self.userpath = nil; - self.userpath2 = nil; - self.paths = nil; - self.executableName = nil; - - [launchArray addObject:@"-c"]; - [launchArray addObject:self.saveBTCConfigFilePath]; - - if ([self.onScrypt isEqualTo:@"--scrypt"]) { - [launchArray removeLastObject]; - [launchArray addObject:self.saveLTCConfigFilePath]; - } - - if ([self.bonusOptions isNotEqualTo:nil]) { - NSArray *bonusStuff = [self.bonusOptions componentsSeparatedByString:@" "]; - if (bonusStuff.count >= 2) { - [launchArray addObjectsFromArray:bonusStuff]; - bonusStuff = nil; - } - } - - // NSString *testString = [launchArray componentsJoinedByString:@" "]; - // NSLog(testString); - - bfgTask=[[TaskWrapper alloc] initWithCommandPath:bfgPath - arguments:launchArray - environment:nil - delegate:self]; - - // kick off the process asynchronously - [bfgTask startTask]; - - NSString *logItString = [launchArray componentsJoinedByString:@"_"]; - appDelegate.bfgSettingText.stringValue = logItString; - appDelegate = nil; - - self.lookupGap = nil; - self.shaders = nil; - self.threadConc = nil; - - - BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:self.saveBTCConfigFilePath]; - if (fileExists) { - NSString *btcConfig = [NSString stringWithContentsOfFile : self.saveBTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; - NSString *ltcConfig = [NSString stringWithContentsOfFile : self.saveLTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; - - - if ([self.onScrypt length] <= 1) { - NSString *numberString = [self getDataBetweenFromString:btcConfig - leftString:@"url" rightString:@"," leftOffset:8]; - NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - numberString = nil; - NSString *acceptString = [self getDataBetweenFromString:btcConfig - leftString:@"user" rightString:@"," leftOffset:9]; - NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - acceptString = nil; - - - NSAlert *startAlert = [[NSAlert alloc] init]; - [startAlert addButtonWithTitle:@"Indeed"]; - - [startAlert setMessageText:@"bfgminer has started"]; - NSString *infoText = [@"The primary pool is set to " stringByAppendingString:bfgURLValue]; - NSString *infoText2 = [infoText stringByAppendingString:@" and the user is set to "]; - NSString *infoText3 = [infoText2 stringByAppendingString:bfgUserValue]; - [startAlert setInformativeText:infoText3]; - - infoText3 = nil; - infoText2 = nil; - infoText = nil; - - // [[NSAlert init] alertWithMessageText:@"This app requires python pip. Click 'Install' and you will be asked your password so it can be installed, or click 'Quit' and install pip yourself before relaunching this app." defaultButton:@"Install" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:nil]; - // NSAlertDefaultReturn = [self performSelector:@selector(installPip:)]; - [startAlert setAlertStyle:NSWarningAlertStyle]; - // returnCode: (NSInteger)returnCode - - [startAlert beginSheetModalForWindow:self.bfgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; - } - - // if ([ltcConfig rangeOfString:stringUser].location != NSNotFound) { - if ([self.onScrypt isEqualTo:@"--scrypt"]) { - NSString *numberString = [self getDataBetweenFromString:ltcConfig - leftString:@"url" rightString:@"," leftOffset:8]; - NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - numberString = nil; - NSString *acceptString = [self getDataBetweenFromString:ltcConfig - leftString:@"user" rightString:@"," leftOffset:9]; - NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - acceptString = nil; - - - NSAlert *startAlert = [[NSAlert alloc] init]; - [startAlert addButtonWithTitle:@"Indeed"]; - - [startAlert setMessageText:@"bfgminer has started"]; - NSString *infoText = [@"The primary pool is set to " stringByAppendingString:bfgURLValue]; - NSString *infoText2 = [infoText stringByAppendingString:@" and the user is set to "]; - NSString *infoText3 = [infoText2 stringByAppendingString:bfgUserValue]; - [startAlert setInformativeText:infoText3]; - - infoText3 = nil; - infoText2 = nil; - infoText = nil; - ltcConfig = nil; - btcConfig = nil; - bfgURLValue = nil; - bfgUserValue = nil; - - - // [[NSAlert init] alertWithMessageText:@"This app requires python pip. Click 'Install' and you will be asked your password so it can be installed, or click 'Quit' and install pip yourself before relaunching this app." defaultButton:@"Install" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:nil]; - // NSAlertDefaultReturn = [self performSelector:@selector(installPip:)]; - [startAlert setAlertStyle:NSWarningAlertStyle]; - // returnCode: (NSInteger)returnCode - - [startAlert beginSheetModalForWindow:self.bfgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; - - } - - - } - - - - - - - launchArray = nil; - - self.intensityValue = nil; - self.worksizeValue = nil; - self.vectorValue = nil; - self.noGPU = nil; - self.onScrypt = nil; - self.debugOutputOn = nil; - self.quietOutputOn = nil; - self.bonusOptions = nil; - - bfgPath = nil; - self.saveBTCConfigFilePath = nil; - self.saveLTCConfigFilePath = nil; - } - prefs = nil; } - (IBAction)bfgMinerToggle:(id)sender { @@ -1185,6 +929,273 @@ - (IBAction)setRecommendedBFGValues:(id)sender { } +-(void)awakeFromNib +{ + + + + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + + [prefs synchronize]; + + if ([[prefs objectForKey:@"startBfg"] isEqualToString:@"start"]) { + + [self.bfgWindow orderFront:nil]; + + [self.bfgStartButton setTitle:@"Stop"]; + // If the task is still sitting around from the last run, release it + if (bfgTask!=nil) { + bfgTask = nil; + } + + + AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; + appDelegate.bfgReading.stringValue = @""; + [appDelegate.bfgReadBack setHidden:NO]; + [appDelegate.bfgReading setHidden:NO]; + + + [[NSApp dockTile] display]; + + + // Let's allocate memory for and initialize a new TaskWrapper object, passing + // in ourselves as the controller for this TaskWrapper object, the path + // to the command-line tool, and the contents of the text field that + // displays what the user wants to search on + + // AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; + + + NSString *bundlePath2 = [[NSBundle mainBundle] resourcePath]; + + NSString *bfgPath = [bundlePath2 stringByAppendingString:@"/bfgminer/bin/bfgminer"]; + + + + [self.bfgOutputView setString:@""]; + NSString *startingText = @"Starting…"; + self.bfgStatLabel.stringValue = startingText; + startingText = nil; + + + NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: nil]; + + + + self.intensityValue = [prefs stringForKey:@"intenseValue"]; + self.worksizeValue = [prefs stringForKey:@"worksizeValue"]; + self.vectorValue = [prefs stringForKey:@"vectorValue"]; + self.noGPU = [prefs stringForKey:@"disableGPU"]; + self.onScrypt = [prefs stringForKey:@"useScrypt"]; + self.debugOutputOn = [prefs stringForKey:@"debugOutput"]; + self.quietOutputOn = [prefs stringForKey:@"quietOutput"]; + self.bonusOptions = [prefs stringForKey:@"bfgOptionsValue"]; + self.threadConc = [prefs stringForKey:@"bfgThreadConc"]; + self.shaders = [prefs stringForKey:@"bfgShaders"]; + self.lookupGap = [prefs stringForKey:@"bfgLookupGap"]; + NSString *cpuThreads = [prefs stringForKey:@"bfgCpuThreads"]; + + + [launchArray addObject:@"-T"]; + + if ([self.intensityValue isNotEqualTo:nil]) { + [launchArray addObject:@"-I"]; + [launchArray addObject:self.intensityValue]; + } + if ([self.worksizeValue isNotEqualTo:nil]) { + [launchArray addObject:@"-w"]; + [launchArray addObject:self.worksizeValue]; + } + if ([self.vectorValue isNotEqualTo:nil]) { + [launchArray addObject:@"-v"]; + [launchArray addObject:self.vectorValue]; + } + if (self.noGPU.length >= 1) { + [launchArray addObject:@"-S"]; + [launchArray addObject:@"opencl:auto"]; + } + if ([self.onScrypt isNotEqualTo:nil]) { + [launchArray addObject:self.onScrypt]; + } + if ([self.debugOutputOn isNotEqualTo:nil]) { + [launchArray addObject:self.debugOutputOn]; + } + if ([self.quietOutputOn isNotEqualTo:nil]) { + [launchArray addObject:self.quietOutputOn]; + } + if (self.threadConc.length >= 1) { + [launchArray addObject:@"--thread-concurrency"]; + [launchArray addObject:self.threadConc]; + } + if (self.shaders.length >= 1) { + [launchArray addObject:@"--shaders"]; + [launchArray addObject:self.shaders]; + } + if (self.lookupGap.length >= 1) { + [launchArray addObject:@"--lookup-gap"]; + [launchArray addObject:self.lookupGap]; + } + if (cpuThreads.length >= 1) { + [launchArray addObject:@"-t"]; + [launchArray addObject:cpuThreads]; + } + else { + [launchArray addObject:@"-t"]; + [launchArray addObject:@"0"]; + } + + self.executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; + self.paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + self.userpath = [self.paths objectAtIndex:0]; + self.userpath2 = [self.userpath stringByAppendingPathComponent:self.executableName]; // The file will go in this directory + self.saveBTCConfigFilePath = [self.userpath2 stringByAppendingPathComponent:@"bfgurls.conf"]; + self.saveLTCConfigFilePath = [self.userpath2 stringByAppendingPathComponent:@"ltcurls.conf"]; + self.userpath = nil; + self.userpath2 = nil; + self.paths = nil; + self.executableName = nil; + + [launchArray addObject:@"-c"]; + [launchArray addObject:self.saveBTCConfigFilePath]; + + if ([self.onScrypt isEqualTo:@"--scrypt"]) { + [launchArray removeLastObject]; + [launchArray addObject:self.saveLTCConfigFilePath]; + } + + if ([self.bonusOptions isNotEqualTo:nil]) { + NSArray *bonusStuff = [self.bonusOptions componentsSeparatedByString:@" "]; + if (bonusStuff.count >= 2) { + [launchArray addObjectsFromArray:bonusStuff]; + bonusStuff = nil; + } + } + + // NSString *testString = [launchArray componentsJoinedByString:@" "]; + // NSLog(testString); + + bfgTask=[[TaskWrapper alloc] initWithCommandPath:bfgPath + arguments:launchArray + environment:nil + delegate:self]; + + // kick off the process asynchronously + [bfgTask startTask]; + + NSString *logItString = [launchArray componentsJoinedByString:@"_"]; + appDelegate.bfgSettingText.stringValue = logItString; + appDelegate = nil; + + self.lookupGap = nil; + self.shaders = nil; + self.threadConc = nil; + + + BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:self.saveBTCConfigFilePath]; + if (fileExists) { + NSString *btcConfig = [NSString stringWithContentsOfFile : self.saveBTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; + NSString *ltcConfig = [NSString stringWithContentsOfFile : self.saveLTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; + + + if ([self.onScrypt length] <= 1) { + NSString *numberString = [self getDataBetweenFromString:btcConfig + leftString:@"url" rightString:@"," leftOffset:8]; + NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + numberString = nil; + NSString *acceptString = [self getDataBetweenFromString:btcConfig + leftString:@"user" rightString:@"," leftOffset:9]; + NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + acceptString = nil; + + + NSAlert *startAlert = [[NSAlert alloc] init]; + [startAlert addButtonWithTitle:@"Indeed"]; + + [startAlert setMessageText:@"bfgminer has started"]; + NSString *infoText = [@"The primary pool is set to " stringByAppendingString:bfgURLValue]; + NSString *infoText2 = [infoText stringByAppendingString:@" and the user is set to "]; + NSString *infoText3 = [infoText2 stringByAppendingString:bfgUserValue]; + [startAlert setInformativeText:infoText3]; + + infoText3 = nil; + infoText2 = nil; + infoText = nil; + + // [[NSAlert init] alertWithMessageText:@"This app requires python pip. Click 'Install' and you will be asked your password so it can be installed, or click 'Quit' and install pip yourself before relaunching this app." defaultButton:@"Install" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:nil]; + // NSAlertDefaultReturn = [self performSelector:@selector(installPip:)]; + [startAlert setAlertStyle:NSWarningAlertStyle]; + // returnCode: (NSInteger)returnCode + + [startAlert beginSheetModalForWindow:self.bfgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; + } + + // if ([ltcConfig rangeOfString:stringUser].location != NSNotFound) { + if ([self.onScrypt isEqualTo:@"--scrypt"]) { + NSString *numberString = [self getDataBetweenFromString:ltcConfig + leftString:@"url" rightString:@"," leftOffset:8]; + NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + numberString = nil; + NSString *acceptString = [self getDataBetweenFromString:ltcConfig + leftString:@"user" rightString:@"," leftOffset:9]; + NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + acceptString = nil; + + + NSAlert *startAlert = [[NSAlert alloc] init]; + [startAlert addButtonWithTitle:@"Indeed"]; + + [startAlert setMessageText:@"bfgminer has started"]; + NSString *infoText = [@"The primary pool is set to " stringByAppendingString:bfgURLValue]; + NSString *infoText2 = [infoText stringByAppendingString:@" and the user is set to "]; + NSString *infoText3 = [infoText2 stringByAppendingString:bfgUserValue]; + [startAlert setInformativeText:infoText3]; + + infoText3 = nil; + infoText2 = nil; + infoText = nil; + ltcConfig = nil; + btcConfig = nil; + bfgURLValue = nil; + bfgUserValue = nil; + + + // [[NSAlert init] alertWithMessageText:@"This app requires python pip. Click 'Install' and you will be asked your password so it can be installed, or click 'Quit' and install pip yourself before relaunching this app." defaultButton:@"Install" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:nil]; + // NSAlertDefaultReturn = [self performSelector:@selector(installPip:)]; + [startAlert setAlertStyle:NSWarningAlertStyle]; + // returnCode: (NSInteger)returnCode + + [startAlert beginSheetModalForWindow:self.bfgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; + + } + + + } + + + + + + + launchArray = nil; + + self.intensityValue = nil; + self.worksizeValue = nil; + self.vectorValue = nil; + self.noGPU = nil; + self.onScrypt = nil; + self.debugOutputOn = nil; + self.quietOutputOn = nil; + self.bonusOptions = nil; + + bfgPath = nil; + self.saveBTCConfigFilePath = nil; + self.saveLTCConfigFilePath = nil; + } + prefs = nil; + + +} + @end diff --git a/MacMiner/cgminerViewController.m b/MacMiner/cgminerViewController.m index 9730293..18ecc5d 100644 --- a/MacMiner/cgminerViewController.m +++ b/MacMiner/cgminerViewController.m @@ -162,7 +162,7 @@ - (IBAction)cgstart:(id)sender [launchArray addObject:@"-T"]; [launchArray addObject:@"--api-listen"]; [launchArray addObject:@"--api-allow"]; - [launchArray addObject:@"W:0/0"]; + [launchArray addObject:@"R:0/0"]; [launchArray addObject:@"--api-port"]; [launchArray addObject:@"4048"]; @@ -504,173 +504,6 @@ -(void)viewDidLoad // [[NSApp dockTile] setContentView:cgdockReading]; // [[NSApp dockTile] display]; - NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; - - [prefs synchronize]; - - if ([[prefs objectForKey:@"startCg"] isEqualToString:@"start"]) { - [self.cgStartButton setTitle:@"Stop"]; - // If the task is still sitting around from the last run, release it - if (cgTask!=nil) { - cgTask = nil; - } - - NSString *filePath = @"/System/Library/Extensions/IOUSBFamily.kext"; - bool b=[[NSFileManager defaultManager] fileExistsAtPath:filePath]; - - NSString *filePath2 = @"/System/Library/Extensions/SiLabsUSBDriver64.kext"; - bool c=[[NSFileManager defaultManager] fileExistsAtPath:filePath2]; - - NSString *filePath3 = @"/System/Library/Extensions/FTDIUSBSerialDriver.kext"; - bool d=[[NSFileManager defaultManager] fileExistsAtPath:filePath3]; - - if (b == YES || c == YES || d == YES) { - NSAlert *driverAlert = [[NSAlert alloc] init]; - [driverAlert addButtonWithTitle:@"Show Instructions"]; - [driverAlert addButtonWithTitle:@"Ignore problem drivers"]; - - [driverAlert setMessageText:@"Driver problem detected"]; - NSString *infoText = @"cgminer conflicts with the native Mac OS 10.9 and other USB Serial drivers. Please click below to see instructions for disabling the default driver."; - - [driverAlert setInformativeText:infoText]; - - - [driverAlert setAlertStyle:NSWarningAlertStyle]; - // returnCode: (NSInteger)returnCode - int rCode = [driverAlert runModal]; - if (rCode == NSAlertFirstButtonReturn) { - - if (b == YES) { - NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; - NSString *urlPath = [bundlePath stringByAppendingString:@"/driverfiles/Instructions.rtf"]; - NSURL* url = [NSURL fileURLWithPath:urlPath isDirectory:YES]; - - NSArray *fileURLs = [NSArray arrayWithObjects:url, nil]; - [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs]; - } - - } - else { - // NSLog(@"Ignore"); - } - - // [driverAlert beginSheetModalForWindow:self.cgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; - - } - - - AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; - appDelegate.cgReading.stringValue = @""; - [appDelegate.cgReadBack setHidden:NO]; - [appDelegate.cgReading setHidden:NO]; - - [[NSApp dockTile] display]; - - NSString *bundlePath2 = [[NSBundle mainBundle] resourcePath]; - - NSString *cgPath = [bundlePath2 stringByAppendingString:@"/cgminer/bin/cgminer"]; - - - // NSString *cgPath = @"/Applications/MacMiner.app/Contents/Resources/cgminer/bin/cgminer"; - - // NSLog(poclbmPath); - [self.cgOutputView setString:@""]; - NSString *startingText = @"Starting…"; - self.cgStatLabel.stringValue = startingText; - startingText = nil; - - - NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: nil]; - - - NSString *bonusOptions = [prefs stringForKey:@"cgOptionsValue"]; - - - [launchArray addObject:@"-T"]; - [launchArray addObject:@"--api-listen"]; - [launchArray addObject:@"--api-allow"]; - [launchArray addObject:@"W:0/0"]; - [launchArray addObject:@"--api-port"]; - [launchArray addObject:@"4048"]; - - - NSString *executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - NSString *userpath = [paths objectAtIndex:0]; - userpath = [userpath stringByAppendingPathComponent:executableName]; // The file will go in this directory - NSString *saveBTCConfigFilePath = [userpath stringByAppendingPathComponent:@"bfgurls.conf"]; - // NSString *saveLTCConfigFilePath = [userpath stringByAppendingPathComponent:@"ltcurls.conf"]; - - [launchArray addObject:@"-c"]; - [launchArray addObject:saveBTCConfigFilePath]; - - - if ([bonusOptions isNotEqualTo:nil]) { - NSArray *bonusStuff = [bonusOptions componentsSeparatedByString:@" "]; - if (bonusStuff.count >= 2) { - [launchArray addObjectsFromArray:bonusStuff]; - bonusStuff = nil; - } - } - - - cgTask=[[TaskWrapper alloc] initWithCommandPath:cgPath - arguments:launchArray - environment:nil - delegate:self]; - - // kick off the process asynchronously - [cgTask startTask]; - - - BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:saveBTCConfigFilePath]; - if (fileExists) { - NSString *btcConfig = [NSString stringWithContentsOfFile : saveBTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; - - - NSString *numberString = [self getDataBetweenFromString:btcConfig - leftString:@"url" rightString:@"," leftOffset:8]; - NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - numberString = nil; - NSString *acceptString = [self getDataBetweenFromString:btcConfig - leftString:@"user" rightString:@"," leftOffset:9]; - NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - acceptString = nil; - - - NSAlert *startAlert = [[NSAlert alloc] init]; - [startAlert addButtonWithTitle:@"Indeed"]; - - [startAlert setMessageText:@"cgminer has started"]; - NSString *infoText = @"The primary pool is set to "; - infoText = [infoText stringByAppendingString:bfgURLValue]; - infoText = [infoText stringByAppendingString:@" and the user is set to "]; - infoText = [infoText stringByAppendingString:bfgUserValue]; - [startAlert setInformativeText:infoText]; - - // [[NSAlert init] alertWithMessageText:@"This app requires python pip. Click 'Install' and you will be asked your password so it can be installed, or click 'Quit' and install pip yourself before relaunching this app." defaultButton:@"Install" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:nil]; - // NSAlertDefaultReturn = [self performSelector:@selector(installPip:)]; - [startAlert setAlertStyle:NSWarningAlertStyle]; - // returnCode: (NSInteger)returnCode - - [startAlert beginSheetModalForWindow:self.cgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; - - - // if ([ltcConfig rangeOfString:stringUser].location != NSNotFound) { - - } - - - - - launchArray = nil; - - bonusOptions = nil; - cgPath = nil; - - } - - prefs = nil; } @@ -865,5 +698,182 @@ - (IBAction)cgDisplayHelp:(id)sender [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://fabulouspanda.co.uk/macminer/docs/"]]; } +-(void)awakeFromNib +{ + + + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + + [prefs synchronize]; + + if ([[prefs objectForKey:@"startCg"] isEqualToString:@"start"]) { + + [self.cgWindow orderFront:nil]; + + [self.cgStartButton setTitle:@"Stop"]; + // If the task is still sitting around from the last run, release it + if (cgTask!=nil) { + cgTask = nil; + } + + NSString *filePath = @"/System/Library/Extensions/IOUSBFamily.kext"; + bool b=[[NSFileManager defaultManager] fileExistsAtPath:filePath]; + + NSString *filePath2 = @"/System/Library/Extensions/SiLabsUSBDriver64.kext"; + bool c=[[NSFileManager defaultManager] fileExistsAtPath:filePath2]; + + NSString *filePath3 = @"/System/Library/Extensions/FTDIUSBSerialDriver.kext"; + bool d=[[NSFileManager defaultManager] fileExistsAtPath:filePath3]; + + if (b == YES || c == YES || d == YES) { + NSAlert *driverAlert = [[NSAlert alloc] init]; + [driverAlert addButtonWithTitle:@"Show Instructions"]; + [driverAlert addButtonWithTitle:@"Ignore problem drivers"]; + + [driverAlert setMessageText:@"Driver problem detected"]; + NSString *infoText = @"cgminer conflicts with the native Mac OS 10.9 and other USB Serial drivers. Please click below to see instructions for disabling the default driver."; + + [driverAlert setInformativeText:infoText]; + + + [driverAlert setAlertStyle:NSWarningAlertStyle]; + // returnCode: (NSInteger)returnCode + int rCode = [driverAlert runModal]; + if (rCode == NSAlertFirstButtonReturn) { + + if (b == YES) { + NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; + NSString *urlPath = [bundlePath stringByAppendingString:@"/driverfiles/Instructions.rtf"]; + NSURL* url = [NSURL fileURLWithPath:urlPath isDirectory:YES]; + + NSArray *fileURLs = [NSArray arrayWithObjects:url, nil]; + [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs]; + } + + } + else { + // NSLog(@"Ignore"); + } + + // [driverAlert beginSheetModalForWindow:self.cgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; + + } + + + AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; + appDelegate.cgReading.stringValue = @""; + [appDelegate.cgReadBack setHidden:NO]; + [appDelegate.cgReading setHidden:NO]; + + [[NSApp dockTile] display]; + + NSString *bundlePath2 = [[NSBundle mainBundle] resourcePath]; + + NSString *cgPath = [bundlePath2 stringByAppendingString:@"/cgminer/bin/cgminer"]; + + + // NSString *cgPath = @"/Applications/MacMiner.app/Contents/Resources/cgminer/bin/cgminer"; + + // NSLog(poclbmPath); + [self.cgOutputView setString:@""]; + NSString *startingText = @"Starting…"; + self.cgStatLabel.stringValue = startingText; + startingText = nil; + + + NSMutableArray *launchArray = [NSMutableArray arrayWithObjects: nil]; + + + NSString *bonusOptions = [prefs stringForKey:@"cgOptionsValue"]; + + + [launchArray addObject:@"-T"]; + [launchArray addObject:@"--api-listen"]; + [launchArray addObject:@"--api-allow"]; + [launchArray addObject:@"R:0/0"]; + [launchArray addObject:@"--api-port"]; + [launchArray addObject:@"4048"]; + + + NSString *executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + NSString *userpath = [paths objectAtIndex:0]; + userpath = [userpath stringByAppendingPathComponent:executableName]; // The file will go in this directory + NSString *saveBTCConfigFilePath = [userpath stringByAppendingPathComponent:@"bfgurls.conf"]; + // NSString *saveLTCConfigFilePath = [userpath stringByAppendingPathComponent:@"ltcurls.conf"]; + + [launchArray addObject:@"-c"]; + [launchArray addObject:saveBTCConfigFilePath]; + + + if ([bonusOptions isNotEqualTo:nil]) { + NSArray *bonusStuff = [bonusOptions componentsSeparatedByString:@" "]; + if (bonusStuff.count >= 2) { + [launchArray addObjectsFromArray:bonusStuff]; + bonusStuff = nil; + } + } + + + cgTask=[[TaskWrapper alloc] initWithCommandPath:cgPath + arguments:launchArray + environment:nil + delegate:self]; + + // kick off the process asynchronously + [cgTask startTask]; + + + BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:saveBTCConfigFilePath]; + if (fileExists) { + NSString *btcConfig = [NSString stringWithContentsOfFile : saveBTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; + + + NSString *numberString = [self getDataBetweenFromString:btcConfig + leftString:@"url" rightString:@"," leftOffset:8]; + NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + numberString = nil; + NSString *acceptString = [self getDataBetweenFromString:btcConfig + leftString:@"user" rightString:@"," leftOffset:9]; + NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + acceptString = nil; + + + NSAlert *startAlert = [[NSAlert alloc] init]; + [startAlert addButtonWithTitle:@"Indeed"]; + + [startAlert setMessageText:@"cgminer has started"]; + NSString *infoText = @"The primary pool is set to "; + infoText = [infoText stringByAppendingString:bfgURLValue]; + infoText = [infoText stringByAppendingString:@" and the user is set to "]; + infoText = [infoText stringByAppendingString:bfgUserValue]; + [startAlert setInformativeText:infoText]; + + // [[NSAlert init] alertWithMessageText:@"This app requires python pip. Click 'Install' and you will be asked your password so it can be installed, or click 'Quit' and install pip yourself before relaunching this app." defaultButton:@"Install" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:nil]; + // NSAlertDefaultReturn = [self performSelector:@selector(installPip:)]; + [startAlert setAlertStyle:NSWarningAlertStyle]; + // returnCode: (NSInteger)returnCode + + [startAlert beginSheetModalForWindow:self.cgWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; + + + // if ([ltcConfig rangeOfString:stringUser].location != NSNotFound) { + + } + + + + + launchArray = nil; + + bonusOptions = nil; + cgPath = nil; + + } + + prefs = nil; + +} + @end diff --git a/MacMiner/cpuminerViewController.m b/MacMiner/cpuminerViewController.m index a5d075d..9b59ec2 100644 --- a/MacMiner/cpuminerViewController.m +++ b/MacMiner/cpuminerViewController.m @@ -29,166 +29,9 @@ - (id)initWithCoder:(NSCoder *)aDecoder self.cpuStatLabel.delegate = self; - NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; - - [prefs synchronize]; - - if ([[prefs objectForKey:@"startBfg"] isEqualToString:@"start"]) { - [self.cpuStartButton setTitle:@"Stop"]; - // If the task is still sitting around from the last run, release it - if (cpuTask!=nil) { - cpuTask = nil; - } - - - - AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; - appDelegate.cpuReading.stringValue = @""; - [appDelegate.cpuReadBack setHidden:NO]; - [appDelegate.cpuReading setHidden:NO]; - - [[NSApp dockTile] display]; - - - - NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; - - [prefs synchronize]; - - - NSString *mainLTCPool = [prefs stringForKey:@"defaultLTCPoolValue"]; - NSString *mainLTCUser = [prefs stringForKey:@"defaultLTCUser"]; - NSString *mainLTCPass = [prefs stringForKey:@"defaultLTCPass"]; - - - NSString *executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - NSString *userpath = [paths objectAtIndex:0]; - userpath = [userpath stringByAppendingPathComponent:executableName]; // The file will go in this directory - NSString *saveLTCConfigFilePath = [userpath stringByAppendingPathComponent:@"ltcurls.conf"]; - - - NSString *stringUser = [[NSString alloc] initWithContentsOfFile:saveLTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; - NSString *userFind = @"user"; - if ([stringUser rangeOfString:userFind].location != NSNotFound) { - NSString *foundURLString = [self getDataBetweenFromString:stringUser - leftString:@"url" rightString:@"," leftOffset:8]; - NSString *URLClean = foundURLString; - mainLTCPool = [URLClean stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - NSString *foundUserString = [self getDataBetweenFromString:stringUser - leftString:@"user" rightString:@"," leftOffset:8]; - NSString *stepClean = foundUserString; - mainLTCUser = [stepClean stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - - NSString *foundPassString = [self getDataBetweenFromString:stringUser - leftString:@"pass" rightString:@"\"" leftOffset:9]; - NSString *passClean = foundPassString; - mainLTCPass = [passClean stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - } - - - - NSString *cpuThreadsV = [prefs stringForKey:@"cpuThreadsValue"]; - // NSString *cpuScryptV = [prefs stringForKey:@"cpuUseScryptValue"]; - NSString *cpuQuietV = [prefs stringForKey:@"cpuQuietOutput"]; - NSString *cpuDebugV = [prefs stringForKey:@"cpuDebugOutput"]; - NSString *cpuOptionsV = [prefs stringForKey:@"cpuOptionsValue"]; - - - NSMutableArray *cpuLaunchArray = [NSMutableArray arrayWithObjects: nil]; - - if ([cpuThreadsV isNotEqualTo:@""]) { - [cpuLaunchArray addObject:@"-t"]; - [cpuLaunchArray addObject:cpuThreadsV]; - } - - [cpuLaunchArray addObject:@"-o"]; - [cpuLaunchArray addObject:mainLTCPool]; - [cpuLaunchArray addObject:@"-u"]; - [cpuLaunchArray addObject:mainLTCUser]; - [cpuLaunchArray addObject:@"-p"]; - [cpuLaunchArray addObject:mainLTCPass]; - - if ([cpuQuietV isNotEqualTo:nil]) { - [cpuLaunchArray addObject:@"-q"]; - } - if ([cpuDebugV isNotEqualTo:nil]) { - [cpuLaunchArray addObject:@"-D"]; - } - - - if ([cpuOptionsV isNotEqualTo:nil]) { - NSArray *cpuBonusStuff = [cpuOptionsV componentsSeparatedByString:@" "]; - if (cpuBonusStuff.count >= 2) { - [cpuLaunchArray addObjectsFromArray:cpuBonusStuff]; - cpuBonusStuff = nil; - } - } - - - NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; - NSString *cpuPath = [bundlePath stringByDeletingLastPathComponent]; - - NSString *cpuPath2 = [cpuPath stringByAppendingString:@"/Resources/minerd"]; - // NSLog(cpuPath); - [self.cpuOutputView setString:@""]; - NSString *startingText = @"Starting…"; - self.cpuStatLabel.stringValue = startingText; - - - cpuTask = [[TaskWrapper alloc] initWithCommandPath:cpuPath2 - arguments:cpuLaunchArray - environment:nil - delegate:self]; - - [cpuTask startTask]; - - BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:saveLTCConfigFilePath]; - if (fileExists) { - - NSString *ltcConfig = [NSString stringWithContentsOfFile : saveLTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; - - - - - NSString *numberString = [self getDataBetweenFromString:ltcConfig - leftString:@"url" rightString:@"," leftOffset:8]; - NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - numberString = nil; - NSString *acceptString = [self getDataBetweenFromString:ltcConfig - leftString:@"user" rightString:@"," leftOffset:9]; - NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - acceptString = nil; - - - NSAlert *startAlert = [[NSAlert alloc] init]; - [startAlert addButtonWithTitle:@"Indeed"]; - - [startAlert setMessageText:@"cpuminer has started"]; - NSString *infoText = [@"The primary pool is set to " stringByAppendingString:bfgURLValue]; - - NSString *infoText2 = [infoText stringByAppendingString:@" and the user is set to "]; - NSString *infoText3 = [infoText2 stringByAppendingString:bfgUserValue]; - [startAlert setInformativeText:infoText3]; - infoText = nil; - infoText2 = nil; - infoText3 = nil; - - - [startAlert setAlertStyle:NSWarningAlertStyle]; - // returnCode: (NSInteger)returnCode - - [startAlert beginSheetModalForWindow:self.cpuWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; - - } - - - - } - } - + return self; @@ -619,6 +462,9 @@ - (IBAction)displayReleaseNotes:(id)sender // control of the UI. -(void)awakeFromNib { + + + findRunning=NO; cpuTask=nil; @@ -627,7 +473,166 @@ -(void)awakeFromNib // NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; // m = [[[XRGModule alloc] initWithName:@"Temperature" andReference:self] retain]; + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + + [prefs synchronize]; + if ([[prefs objectForKey:@"startBfg"] isEqualToString:@"start"]) { + + [self.cpuWindow orderFront:nil]; + + [self.cpuStartButton setTitle:@"Stop"]; + // If the task is still sitting around from the last run, release it + if (cpuTask!=nil) { + cpuTask = nil; + } + + + + AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; + appDelegate.cpuReading.stringValue = @""; + [appDelegate.cpuReadBack setHidden:NO]; + [appDelegate.cpuReading setHidden:NO]; + + [[NSApp dockTile] display]; + + + + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + + [prefs synchronize]; + + + NSString *mainLTCPool = [prefs stringForKey:@"defaultLTCPoolValue"]; + NSString *mainLTCUser = [prefs stringForKey:@"defaultLTCUser"]; + NSString *mainLTCPass = [prefs stringForKey:@"defaultLTCPass"]; + + + NSString *executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + NSString *userpath = [paths objectAtIndex:0]; + userpath = [userpath stringByAppendingPathComponent:executableName]; // The file will go in this directory + NSString *saveLTCConfigFilePath = [userpath stringByAppendingPathComponent:@"ltcurls.conf"]; + + + NSString *stringUser = [[NSString alloc] initWithContentsOfFile:saveLTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; + NSString *userFind = @"user"; + if ([stringUser rangeOfString:userFind].location != NSNotFound) { + NSString *foundURLString = [self getDataBetweenFromString:stringUser + leftString:@"url" rightString:@"," leftOffset:8]; + NSString *URLClean = foundURLString; + mainLTCPool = [URLClean stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + NSString *foundUserString = [self getDataBetweenFromString:stringUser + leftString:@"user" rightString:@"," leftOffset:8]; + NSString *stepClean = foundUserString; + mainLTCUser = [stepClean stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + + NSString *foundPassString = [self getDataBetweenFromString:stringUser + leftString:@"pass" rightString:@"\"" leftOffset:9]; + NSString *passClean = foundPassString; + mainLTCPass = [passClean stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + } + + + + NSString *cpuThreadsV = [prefs stringForKey:@"cpuThreadsValue"]; + // NSString *cpuScryptV = [prefs stringForKey:@"cpuUseScryptValue"]; + NSString *cpuQuietV = [prefs stringForKey:@"cpuQuietOutput"]; + NSString *cpuDebugV = [prefs stringForKey:@"cpuDebugOutput"]; + NSString *cpuOptionsV = [prefs stringForKey:@"cpuOptionsValue"]; + + + NSMutableArray *cpuLaunchArray = [NSMutableArray arrayWithObjects: nil]; + + if ([cpuThreadsV isNotEqualTo:@""]) { + [cpuLaunchArray addObject:@"-t"]; + [cpuLaunchArray addObject:cpuThreadsV]; + } + + [cpuLaunchArray addObject:@"-o"]; + [cpuLaunchArray addObject:mainLTCPool]; + [cpuLaunchArray addObject:@"-u"]; + [cpuLaunchArray addObject:mainLTCUser]; + [cpuLaunchArray addObject:@"-p"]; + [cpuLaunchArray addObject:mainLTCPass]; + + if ([cpuQuietV isNotEqualTo:nil]) { + [cpuLaunchArray addObject:@"-q"]; + } + if ([cpuDebugV isNotEqualTo:nil]) { + [cpuLaunchArray addObject:@"-D"]; + } + + + if ([cpuOptionsV isNotEqualTo:nil]) { + NSArray *cpuBonusStuff = [cpuOptionsV componentsSeparatedByString:@" "]; + if (cpuBonusStuff.count >= 2) { + [cpuLaunchArray addObjectsFromArray:cpuBonusStuff]; + cpuBonusStuff = nil; + } + } + + + NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; + NSString *cpuPath = [bundlePath stringByDeletingLastPathComponent]; + + NSString *cpuPath2 = [cpuPath stringByAppendingString:@"/Resources/minerd"]; + // NSLog(cpuPath); + [self.cpuOutputView setString:@""]; + NSString *startingText = @"Starting…"; + self.cpuStatLabel.stringValue = startingText; + + + cpuTask = [[TaskWrapper alloc] initWithCommandPath:cpuPath2 + arguments:cpuLaunchArray + environment:nil + delegate:self]; + + [cpuTask startTask]; + + BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:saveLTCConfigFilePath]; + if (fileExists) { + + NSString *ltcConfig = [NSString stringWithContentsOfFile : saveLTCConfigFilePath encoding:NSUTF8StringEncoding error:nil]; + + + + + NSString *numberString = [self getDataBetweenFromString:ltcConfig + leftString:@"url" rightString:@"," leftOffset:8]; + NSString *bfgURLValue = [numberString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + numberString = nil; + NSString *acceptString = [self getDataBetweenFromString:ltcConfig + leftString:@"user" rightString:@"," leftOffset:9]; + NSString *bfgUserValue = [acceptString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; + acceptString = nil; + + + NSAlert *startAlert = [[NSAlert alloc] init]; + [startAlert addButtonWithTitle:@"Indeed"]; + + [startAlert setMessageText:@"cpuminer has started"]; + NSString *infoText = [@"The primary pool is set to " stringByAppendingString:bfgURLValue]; + + NSString *infoText2 = [infoText stringByAppendingString:@" and the user is set to "]; + NSString *infoText3 = [infoText2 stringByAppendingString:bfgUserValue]; + [startAlert setInformativeText:infoText3]; + infoText = nil; + infoText2 = nil; + infoText3 = nil; + + + [startAlert setAlertStyle:NSWarningAlertStyle]; + // returnCode: (NSInteger)returnCode + + [startAlert beginSheetModalForWindow:self.cpuWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; + + } + + + + } + prefs = nil; } - (IBAction)cpuMinerToggle:(id)sender { diff --git a/MacMiner/en.lproj/MainMenu.xib b/MacMiner/en.lproj/MainMenu.xib index 5f02159..cf6a28f 100644 --- a/MacMiner/en.lproj/MainMenu.xib +++ b/MacMiner/en.lproj/MainMenu.xib @@ -3860,7 +3860,7 @@ for his help with C/C++ code - + diff --git a/cgminer/bin/cgminer b/cgminer/bin/cgminer index 6b8f9f6..ec69d64 100755 Binary files a/cgminer/bin/cgminer and b/cgminer/bin/cgminer differ diff --git a/cgminer/include/libusb-1.0/libusb.h b/cgminer/include/libusb-1.0/libusb.h index f3a8f38..409b510 100644 --- a/cgminer/include/libusb-1.0/libusb.h +++ b/cgminer/include/libusb-1.0/libusb.h @@ -1,9 +1,10 @@ /* * Public libusb header file - * Copyright (C) 2007-2008 Daniel Drake - * Copyright (c) 2001 Johannes Erdfelt - * Copyright (C) 2012-2013 Nathan Hjelm - * Copyright (C) 2012 Peter Stuge + * Copyright © 2001 Johannes Erdfelt + * Copyright © 2007-2008 Daniel Drake + * Copyright © 2012 Pete Batard + * Copyright © 2012 Nathan Hjelm + * For more information, please visit: http://libusb.info * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,7 +26,9 @@ #ifdef _MSC_VER /* on MS environments, the inline keyword is available in C++ only */ +#if !defined(__cplusplus) #define inline __inline +#endif /* ssize_t is also not available (copy/paste from MinGW) */ #ifndef _SSIZE_T_DEFINED #define _SSIZE_T_DEFINED @@ -38,7 +41,7 @@ #endif /* _SSIZE_T_DEFINED */ #endif /* _MSC_VER */ -/* stdint.h is also not usually available on MS */ +/* stdint.h is not available on older MSVC */ #if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H)) typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; @@ -47,26 +50,39 @@ typedef unsigned __int32 uint32_t; #include #endif +#if !defined(_WIN32_WCE) #include -#include -#include +#endif #if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__) #include #endif +#include +#include + /* 'interface' might be defined as a macro on Windows, so we need to * undefine it so as not to break the current libusb API, because * libusb_config_descriptor has an 'interface' member * As this can be problematic if you include windows.h after libusb.h * in your sources, we force windows.h to be included first. */ -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) #include #if defined(interface) #undef interface #endif +#if !defined(__CYGWIN__) +#include +#endif #endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#define LIBUSB_DEPRECATED_FOR(f) \ + __attribute__((deprecated("Use " #f " instead"))) +#else +#define LIBUSB_DEPRECATED_FOR(f) +#endif /* __GNUC__ */ + /** \def LIBUSB_CALL * \ingroup misc * libusb's Windows calling convention. @@ -99,17 +115,45 @@ typedef unsigned __int32 uint32_t; * return type, before the function name. See internal documentation for * API_EXPORTED. */ -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) #define LIBUSB_CALL WINAPI #else #define LIBUSB_CALL #endif +/** \def LIBUSB_API_VERSION + * \ingroup misc + * libusb's API version. + * + * Since version 1.0.13, to help with feature detection, libusb defines + * a LIBUSB_API_VERSION macro that gets increased every time there is a + * significant change to the API, such as the introduction of a new call, + * the definition of a new macro/enum member, or any other element that + * libusb applications may want to detect at compilation time. + * + * The macro is typically used in an application as follows: + * \code + * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234) + * // Use one of the newer features from the libusb API + * #endif + * \endcode + * + * Another feature of LIBUSB_API_VERSION is that it can be used to detect + * whether you are compiling against the libusb or the libusb library. + * + * Internally, LIBUSB_API_VERSION is defined as follows: + * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental) + */ +#define LIBUSB_API_VERSION 0x01000102 + +/* The following is kept for compatibility, but will be deprecated in the future */ +#define LIBUSBX_API_VERSION LIBUSB_API_VERSION + #ifdef __cplusplus extern "C" { #endif -/** \def libusb_cpu_to_le16 +/** * \ingroup misc * Convert a 16-bit value from host-endian to little-endian format. On * little endian systems, this function does nothing. On big endian systems, @@ -123,8 +167,8 @@ static inline uint16_t libusb_cpu_to_le16(const uint16_t x) uint8_t b8[2]; uint16_t b16; } _tmp; - _tmp.b8[1] = x >> 8; - _tmp.b8[0] = x & 0xff; + _tmp.b8[1] = (uint8_t) (x >> 8); + _tmp.b8[0] = (uint8_t) (x & 0xff); return _tmp.b16; } @@ -220,6 +264,12 @@ enum libusb_descriptor_type { /** Endpoint descriptor. See libusb_endpoint_descriptor. */ LIBUSB_DT_ENDPOINT = 0x05, + /** BOS descriptor */ + LIBUSB_DT_BOS = 0x0f, + + /** Device Capability descriptor */ + LIBUSB_DT_DEVICE_CAPABILITY = 0x10, + /** HID descriptor */ LIBUSB_DT_HID = 0x21, @@ -232,11 +282,8 @@ enum libusb_descriptor_type { /** Hub descriptor */ LIBUSB_DT_HUB = 0x29, - /** BOS descriptor */ - LIBUSB_DT_BOS = 0x0f, - - /** Device Capability descriptor */ - LIBUSB_DT_DEVICE_CAPABILITY = 0x10, + /** SuperSpeed Hub descriptor */ + LIBUSB_DT_SUPERSPEED_HUB = 0x2a, /** SuperSpeed Endpoint Companion descriptor */ LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30 @@ -246,16 +293,23 @@ enum libusb_descriptor_type { #define LIBUSB_DT_DEVICE_SIZE 18 #define LIBUSB_DT_CONFIG_SIZE 9 #define LIBUSB_DT_INTERFACE_SIZE 9 -#define LIBUSB_DT_ENDPOINT_SIZE 7 -#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ +#define LIBUSB_DT_ENDPOINT_SIZE 7 +#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ #define LIBUSB_DT_HUB_NONVAR_SIZE 7 -#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6 +#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6 #define LIBUSB_DT_BOS_SIZE 5 -#define LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE 7 -#define LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE 10 -#define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) + \ - (LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE) + \ - (LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE)) +#define LIBUSB_DT_DEVICE_CAPABILITY_SIZE 3 + +/* BOS descriptor sizes */ +#define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7 +#define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10 +#define LIBUSB_BT_CONTAINER_ID_SIZE 20 + +/* We unwrap the BOS => define its max size */ +#define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) +\ + (LIBUSB_BT_USB_2_0_EXTENSION_SIZE) +\ + (LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) +\ + (LIBUSB_BT_CONTAINER_ID_SIZE)) #define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ #define LIBUSB_ENDPOINT_DIR_MASK 0x80 @@ -293,7 +347,7 @@ enum libusb_transfer_type { }; /** \ingroup misc - * Standard requests, as defined in table 9-3 of the USB2 specifications */ + * Standard requests, as defined in table 9-5 of the USB 3.0 specifications */ enum libusb_standard_request { /** Request status of the specific recipient */ LIBUSB_REQUEST_GET_STATUS = 0x00, @@ -331,6 +385,13 @@ enum libusb_standard_request { /** Set then report an endpoint's synchronization frame */ LIBUSB_REQUEST_SYNCH_FRAME = 0x0C, + + /** Sets both the U1 and U2 Exit Latency */ + LIBUSB_REQUEST_SET_SEL = 0x30, + + /** Delay from the time a host transmits a packet to the time it is + * received by the device. */ + LIBUSB_SET_ISOCH_DELAY = 0x31, }; /** \ingroup misc @@ -410,7 +471,7 @@ enum libusb_iso_usage_type { /** \ingroup desc * A structure representing the standard USB device descriptor. This - * descriptor is documented in section 9.6.1 of the USB 2.0 specification. + * descriptor is documented in section 9.6.1 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. */ struct libusb_device_descriptor { @@ -462,41 +523,9 @@ struct libusb_device_descriptor { uint8_t bNumConfigurations; }; -/** \ingroup desc - * A structure representing the superspeed endpoint companion - * descriptor. This descriptor is documented in section 9.6.7 of - * the USB 3.0 specification. All ultiple-byte fields are represented in - * host-endian format. - */ -struct libusb_ss_endpoint_companion_descriptor { - - /** Size of this descriptor (in bytes) */ - uint8_t bLength; - - /** Descriptor type. Will have value - * \ref libusb_descriptor_type::LIBUSB_DT_SS_ENDPOINT_COMPANION in - * this context. */ - uint8_t bDescriptorType; - - - /** The maximum number of packets the endpoint can send or - * recieve as part of a burst. */ - uint8_t bMaxBurst; - - /** In bulk EP: bits 4:0 represents the maximum number of - * streams the EP supports. In isochronous EP: bits 1:0 - * represents the Mult - a zero based value that determines - * the maximum number of packets within a service interval */ - uint8_t bmAttributes; - - /** The total number of bytes this EP will transfer every - * service interval. valid only for periodic EPs. */ - uint16_t wBytesPerInterval; -}; - /** \ingroup desc * A structure representing the standard USB endpoint descriptor. This - * descriptor is documented in section 9.6.3 of the USB 2.0 specification. + * descriptor is documented in section 9.6.6 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. */ struct libusb_endpoint_descriptor { @@ -544,10 +573,9 @@ struct libusb_endpoint_descriptor { int extra_length; }; - /** \ingroup desc * A structure representing the standard USB interface descriptor. This - * descriptor is documented in section 9.6.5 of the USB 2.0 specification. + * descriptor is documented in section 9.6.5 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. */ struct libusb_interface_descriptor { @@ -609,7 +637,7 @@ struct libusb_interface { /** \ingroup desc * A structure representing the standard USB configuration descriptor. This - * descriptor is documented in section 9.6.3 of the USB 2.0 specification. + * descriptor is documented in section 9.6.3 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. */ struct libusb_config_descriptor { @@ -654,11 +682,66 @@ struct libusb_config_descriptor { }; /** \ingroup desc - * A structure representing the BOS descriptor. This - * descriptor is documented in section 9.6.2 of the USB 3.0 - * specification. All multiple-byte fields are represented in + * A structure representing the superspeed endpoint companion + * descriptor. This descriptor is documented in section 9.6.7 of + * the USB 3.0 specification. All multiple-byte fields are represented in * host-endian format. */ +struct libusb_ss_endpoint_companion_descriptor { + + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_SS_ENDPOINT_COMPANION in + * this context. */ + uint8_t bDescriptorType; + + + /** The maximum number of packets the endpoint can send or + * recieve as part of a burst. */ + uint8_t bMaxBurst; + + /** In bulk EP: bits 4:0 represents the maximum number of + * streams the EP supports. In isochronous EP: bits 1:0 + * represents the Mult - a zero based value that determines + * the maximum number of packets within a service interval */ + uint8_t bmAttributes; + + /** The total number of bytes this EP will transfer every + * service interval. valid only for periodic EPs. */ + uint16_t wBytesPerInterval; +}; + +/** \ingroup desc + * A generic representation of a BOS Device Capability descriptor. It is + * advised to check bDevCapabilityType and call the matching + * libusb_get_*_descriptor function to get a structure fully matching the type. + */ +struct libusb_bos_dev_capability_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY + * LIBUSB_DT_DEVICE_CAPABILITY in this context. */ + uint8_t bDescriptorType; + /** Device Capability type */ + uint8_t bDevCapabilityType; + /** Device Capability data (bLength - 3 bytes) */ + uint8_t dev_capability_data +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) + [] /* valid C99 code */ +#else + [0] /* non-standard, but usually working code */ +#endif + ; +}; + +/** \ingroup desc + * A structure representing the Binary Device Object Store (BOS) descriptor. + * This descriptor is documented in section 9.6.2 of the USB 3.0 specification. + * All multiple-byte fields are represented in host-endian format. + */ struct libusb_bos_descriptor { /** Size of this descriptor (in bytes) */ uint8_t bLength; @@ -675,20 +758,22 @@ struct libusb_bos_descriptor { * the BOS */ uint8_t bNumDeviceCaps; - /** USB 2.0 extension capability descriptor */ - struct libusb_usb_2_0_device_capability_descriptor *usb_2_0_ext_cap; - - /** SuperSpeed capabilty descriptor */ - struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap; + /** bNumDeviceCap Device Capability Descriptors */ + struct libusb_bos_dev_capability_descriptor *dev_capability +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) + [] /* valid C99 code */ +#else + [0] /* non-standard, but usually working code */ +#endif + ; }; /** \ingroup desc - * A structure representing the device capability descriptor for - * USB 2.0. This descriptor is documented in section 9.6.2.1 of - * the USB 3.0 specification. All mutiple-byte fields are represented - * in host-endian format. + * A structure representing the USB 2.0 Extension descriptor + * This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification. + * All multiple-byte fields are represented in host-endian format. */ -struct libusb_usb_2_0_device_capability_descriptor { +struct libusb_usb_2_0_extension_descriptor { /** Size of this descriptor (in bytes) */ uint8_t bLength; @@ -698,22 +783,21 @@ struct libusb_usb_2_0_device_capability_descriptor { uint8_t bDescriptorType; /** Capability type. Will have value - * \ref libusb_capability_type::LIBUSB_USB_CAP_TYPE_EXT - * LIBUSB_USB_CAP_TYPE_EXT in this context. */ + * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION + * LIBUSB_BT_USB_2_0_EXTENSION in this context. */ uint8_t bDevCapabilityType; /** Bitmap encoding of supported device level features. * A value of one in a bit location indicates a feature is * supported; a value of zero indicates it is not supported. - * See \ref libusb_capability_attributes. */ + * See \ref libusb_usb_2_0_extension_attributes. */ uint32_t bmAttributes; }; /** \ingroup desc - * A structure representing the device capability descriptor for - * USB 3.0. This descriptor is documented in section 9.6.2.2 of - * the USB 3.0 specification. All mutiple-byte fields are represented - * in host-endian format. + * A structure representing the SuperSpeed USB Device Capability descriptor + * This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification. + * All multiple-byte fields are represented in host-endian format. */ struct libusb_ss_usb_device_capability_descriptor { /** Size of this descriptor (in bytes) */ @@ -725,14 +809,14 @@ struct libusb_ss_usb_device_capability_descriptor { uint8_t bDescriptorType; /** Capability type. Will have value - * \ref libusb_capability_type::LIBUSB_SS_USB_CAP_TYPE - * LIBUSB_SS_USB_CAP_TYPE in this context. */ + * \ref libusb_capability_type::LIBUSB_BT_SS_USB_DEVICE_CAPABILITY + * LIBUSB_BT_SS_USB_DEVICE_CAPABILITY in this context. */ uint8_t bDevCapabilityType; /** Bitmap encoding of supported device level features. * A value of one in a bit location indicates a feature is * supported; a value of zero indicates it is not supported. - * See \ref libusb_capability_attributes. */ + * See \ref libusb_ss_usb_device_capability_attributes. */ uint8_t bmAttributes; /** Bitmap encoding of the speed supported by this device when @@ -752,6 +836,31 @@ struct libusb_ss_usb_device_capability_descriptor { uint16_t bU2DevExitLat; }; +/** \ingroup desc + * A structure representing the Container ID descriptor. + * This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification. + * All multiple-byte fields, except UUIDs, are represented in host-endian format. + */ +struct libusb_container_id_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY + * LIBUSB_DT_DEVICE_CAPABILITY in this context. */ + uint8_t bDescriptorType; + + /** Capability type. Will have value + * \ref libusb_capability_type::LIBUSB_BT_CONTAINER_ID + * LIBUSB_BT_CONTAINER_ID in this context. */ + uint8_t bDevCapabilityType; + + /** Reserved field */ + uint8_t bReserved; + + /** 128 bit UUID */ + uint8_t ContainerID[16]; +}; /** \ingroup asyncio * Setup packet for control transfers. */ @@ -791,7 +900,7 @@ struct libusb_device_handle; struct libusb_hotplug_callback; /** \ingroup lib - * Structure representing the libusb version. + * Structure providing the version of the libusb runtime */ struct libusb_version { /** Library major version. */ @@ -803,14 +912,14 @@ struct libusb_version { /** Library micro version. */ const uint16_t micro; - /** Library nano version. This field is only nonzero on Windows. */ + /** Library nano version. */ const uint16_t nano; /** Library release candidate suffix string, e.g. "-rc4". */ const char *rc; - /** Output of `git describe --tags` at library build time. */ - const char *describe; + /** For ABI compatibility only. */ + const char* describe; }; /** \ingroup lib @@ -864,20 +973,20 @@ typedef struct libusb_device_handle libusb_device_handle; * Speed codes. Indicates the speed at which the device is operating. */ enum libusb_speed { - /** The OS doesn't report or know the device speed. */ - LIBUSB_SPEED_UNKNOWN = 0, + /** The OS doesn't report or know the device speed. */ + LIBUSB_SPEED_UNKNOWN = 0, - /** The device is operating at low speed (1.5MBit/s). */ - LIBUSB_SPEED_LOW = 1, + /** The device is operating at low speed (1.5MBit/s). */ + LIBUSB_SPEED_LOW = 1, - /** The device is operating at full speed (12MBit/s). */ - LIBUSB_SPEED_FULL = 2, + /** The device is operating at full speed (12MBit/s). */ + LIBUSB_SPEED_FULL = 2, - /** The device is operating at high speed (480MBit/s). */ - LIBUSB_SPEED_HIGH = 3, + /** The device is operating at high speed (480MBit/s). */ + LIBUSB_SPEED_HIGH = 3, - /** The device is operating at super speed (5000MBit/s). */ - LIBUSB_SPEED_SUPER = 4, + /** The device is operating at super speed (5000MBit/s). */ + LIBUSB_SPEED_SUPER = 4, }; /** \ingroup dev @@ -886,43 +995,61 @@ enum libusb_speed { */ enum libusb_supported_speed { /** Low speed operation supported (1.5MBit/s). */ - LIBUSB_LOW_SPEED_OPERATION = 1, + LIBUSB_LOW_SPEED_OPERATION = 1, /** Full speed operation supported (12MBit/s). */ - LIBUSB_FULL_SPEED_OPERATION = 2, + LIBUSB_FULL_SPEED_OPERATION = 2, /** High speed operation supported (480MBit/s). */ - LIBUSB_HIGH_SPEED_OPERATION = 4, + LIBUSB_HIGH_SPEED_OPERATION = 4, /** Superspeed operation supported (5000MBit/s). */ - LIBUSB_5GBPS_OPERATION = 8, + LIBUSB_SUPER_SPEED_OPERATION = 8, }; /** \ingroup dev - * Capability attributes + * Masks for the bits of the + * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field + * of the USB 2.0 Extension descriptor. */ -enum libusb_capability_attributes { +enum libusb_usb_2_0_extension_attributes { /** Supports Link Power Management (LPM) */ - LIBUSB_LPM_SUPPORT = 2, + LIBUSB_BM_LPM_SUPPORT = 2, +}; + +/** \ingroup dev + * Masks for the bits of the + * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field + * field of the SuperSpeed USB Device Capability descriptor. + */ +enum libusb_ss_usb_device_capability_attributes { + /** Supports Latency Tolerance Messages (LTM) */ + LIBUSB_BM_LTM_SUPPORT = 2, }; /** \ingroup dev * USB capability types */ -enum libusb_capability_type { - /** USB 2.0 extension capability type */ - LIBUSB_USB_CAP_TYPE_EXT = 2, +enum libusb_bos_type { + /** Wireless USB device capability */ + LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1, - /** SuperSpeed capability type */ - LIBUSB_SS_USB_CAP_TYPE = 3, + /** USB 2.0 extensions */ + LIBUSB_BT_USB_2_0_EXTENSION = 2, + + /** SuperSpeed USB device capability */ + LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3, + + /** Container ID type */ + LIBUSB_BT_CONTAINER_ID = 4, }; /** \ingroup misc * Error codes. Most libusb functions return 0 on success or one of these * codes on failure. - * You can call \ref libusb_error_name() to retrieve a string representation - * of an error code or \ret libusb_strerror() to get an english description - * of an error code. + * You can call libusb_error_name() to retrieve a string representation of an + * error code or libusb_strerror() to get an end-user suitable description of + * an error code. */ enum libusb_error { /** Success (no error) */ @@ -964,13 +1091,16 @@ enum libusb_error { /** Operation not supported or unimplemented on this platform */ LIBUSB_ERROR_NOT_SUPPORTED = -12, - /* NB! Remember to update libusb_error_name() and - libusb_strerror() when adding new error codes here. */ + /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the + message strings in strerror.c when adding new error codes here. */ /** Other error */ LIBUSB_ERROR_OTHER = -99, }; +/* Total number of error codes in enum libusb_error */ +#define LIBUSB_ERROR_COUNT 14 + /** \ingroup asyncio * Transfer status codes */ enum libusb_transfer_status { @@ -996,6 +1126,9 @@ enum libusb_transfer_status { /** Device sent more data than requested */ LIBUSB_TRANSFER_OVERFLOW, + + /* NB! Remember to update libusb_error_name() + when adding new status codes here. */ }; /** \ingroup asyncio @@ -1130,15 +1263,41 @@ struct libusb_transfer { }; /** \ingroup misc - * Capabilities supported by this instance of libusb. Test if the loaded - * library supports a given capability by calling + * Capabilities supported by an instance of libusb on the current running + * platform. Test if the loaded library supports a given capability by calling * \ref libusb_has_capability(). */ enum libusb_capability { /** The libusb_has_capability() API is available. */ - LIBUSB_CAP_HAS_CAPABILITY = 0, - /** The libusb hotplug API is available. */ - LIBUSB_CAP_HAS_HOTPLUG = 1, + LIBUSB_CAP_HAS_CAPABILITY = 0x0000, + /** Hotplug support is available on this platform. */ + LIBUSB_CAP_HAS_HOTPLUG = 0x0001, + /** The library can access HID devices without requiring user intervention. + * Note that before being able to actually access an HID device, you may + * still have to call additional libusb functions such as + * \ref libusb_detach_kernel_driver(). */ + LIBUSB_CAP_HAS_HID_ACCESS = 0x0100, + /** The library supports detaching of the default USB driver, using + * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */ + LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101 +}; + +/** \ingroup lib + * Log message levels. + * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default) + * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr + * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr + * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning + * and error messages are printed to stderr + * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout, + * warnings and errors to stderr + */ +enum libusb_log_level { + LIBUSB_LOG_LEVEL_NONE = 0, + LIBUSB_LOG_LEVEL_ERROR, + LIBUSB_LOG_LEVEL_WARNING, + LIBUSB_LOG_LEVEL_INFO, + LIBUSB_LOG_LEVEL_DEBUG, }; int LIBUSB_CALL libusb_init(libusb_context **ctx); @@ -1147,6 +1306,7 @@ void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level); const struct libusb_version * LIBUSB_CALL libusb_get_version(void); int LIBUSB_CALL libusb_has_capability(uint32_t capability); const char * LIBUSB_CALL libusb_error_name(int errcode); +int LIBUSB_CALL libusb_setlocale(const char *locale); const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode); ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx, @@ -1168,7 +1328,38 @@ int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config); void LIBUSB_CALL libusb_free_config_descriptor( struct libusb_config_descriptor *config); +int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor( + struct libusb_context *ctx, + const struct libusb_endpoint_descriptor *endpoint, + struct libusb_ss_endpoint_companion_descriptor **ep_comp); +void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor( + struct libusb_ss_endpoint_companion_descriptor *ep_comp); +int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *handle, + struct libusb_bos_descriptor **bos); +void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos); +int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor( + struct libusb_context *ctx, + struct libusb_bos_dev_capability_descriptor *dev_cap, + struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension); +void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor( + struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension); +int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor( + struct libusb_context *ctx, + struct libusb_bos_dev_capability_descriptor *dev_cap, + struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap); +void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor( + struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap); +int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *ctx, + struct libusb_bos_dev_capability_descriptor *dev_cap, + struct libusb_container_id_descriptor **container_id); +void LIBUSB_CALL libusb_free_container_id_descriptor( + struct libusb_container_id_descriptor *container_id); uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev); +uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev); +int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len); +LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers) +int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length); +libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev); uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev); int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev); int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev, @@ -1202,6 +1393,8 @@ int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev, int interface_number); int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number); +int LIBUSB_CALL libusb_set_auto_detach_kernel_driver( + libusb_device_handle *dev, int enable); /* async I/O */ @@ -1238,7 +1431,7 @@ static inline unsigned char *libusb_control_transfer_get_data( static inline struct libusb_control_setup *libusb_control_transfer_get_setup( struct libusb_transfer *transfer) { - return (struct libusb_control_setup *) transfer->buffer; + return (struct libusb_control_setup *)(void *) transfer->buffer; } /** \ingroup asyncio @@ -1247,6 +1440,7 @@ static inline struct libusb_control_setup *libusb_control_transfer_get_setup( * be given in host-endian byte order. * * \param buffer buffer to output the setup packet into + * This pointer must be aligned to at least 2 bytes boundary. * \param bmRequestType see the * \ref libusb_control_setup::bmRequestType "bmRequestType" field of * \ref libusb_control_setup @@ -1267,7 +1461,7 @@ static inline void libusb_fill_control_setup(unsigned char *buffer, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength) { - struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; + struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer; setup->bmRequestType = bmRequestType; setup->bRequest = bRequest; setup->wValue = libusb_cpu_to_le16(wValue); @@ -1303,6 +1497,7 @@ void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer); * \param dev_handle handle of the device that will handle the transfer * \param buffer data buffer. If provided, this function will interpret the * first 8 bytes as a setup packet and infer the transfer length from that. + * This pointer must be aligned to at least 2 bytes boundary. * \param callback callback function to be invoked on transfer completion * \param user_data user data to pass to callback function * \param timeout timeout for the transfer in milliseconds @@ -1312,15 +1507,15 @@ static inline void libusb_fill_control_transfer( unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) { - struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; + struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer; transfer->dev_handle = dev_handle; transfer->endpoint = 0; transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL; transfer->timeout = timeout; transfer->buffer = buffer; if (setup) - transfer->length = LIBUSB_CONTROL_SETUP_SIZE - + libusb_le16_to_cpu(setup->wLength); + transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE + + libusb_le16_to_cpu(setup->wLength)); transfer->user_data = user_data; transfer->callback = callback; } @@ -1455,7 +1650,7 @@ static inline unsigned char *libusb_get_iso_packet_buffer( * signed to avoid compiler warnings. FIXME for libusb-2. */ if (packet > INT_MAX) return NULL; - _packet = packet; + _packet = (int) packet; if (_packet >= transfer->num_iso_packets) return NULL; @@ -1495,12 +1690,12 @@ static inline unsigned char *libusb_get_iso_packet_buffer_simple( * signed to avoid compiler warnings. FIXME for libusb-2. */ if (packet > INT_MAX) return NULL; - _packet = packet; + _packet = (int) packet; if (_packet >= transfer->num_iso_packets) return NULL; - return transfer->buffer + (transfer->iso_packet_desc[0].length * _packet); + return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet); } /* sync I/O */ @@ -1533,8 +1728,8 @@ static inline int libusb_get_descriptor(libusb_device_handle *dev, uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length) { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, - LIBUSB_REQUEST_GET_DESCRIPTOR, (desc_type << 8) | desc_index, 0, data, - (uint16_t) length, 1000); + LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index), + 0, data, (uint16_t) length, 1000); } /** \ingroup desc @@ -1629,48 +1824,6 @@ void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data); -/** \ingroup desc - * Parse a USB 3.0 endpoint companion descriptor. - * - * \param[in] buf the buffer containing the endpoint companion descriptor - * \param[in] len the length of the buffer - * \param[out] ep_comp a parsed endpoint companion descriptor. must be freed by - * libusb_free_ss_endpoint_comp() - * - * \returns LIBUSB_SUCCESS on success - * \returns LIBUSB_ERROR code on error - */ -int LIBUSB_CALL libusb_parse_ss_endpoint_comp(const void *buf, int len, - struct libusb_ss_endpoint_companion_descriptor **ep_comp); - -/** \ingroup desc - * Free a USB 3.0 endpoint companion descriptor. - * - * \param[in] ep_comp the descriptor to free - */ -void LIBUSB_CALL libusb_free_ss_endpoint_comp(struct libusb_ss_endpoint_companion_descriptor *ep_comp); - -/** \ingroup desc - * Parse a Binary Object Store (BOS) descriptor. - * - * \param[in] buf the buffer containing the BOS descriptor - * \param[in] len the length of the buffer - * \param[out] bos a parsed BOS descriptor. must be freed by - * libusb_free_bos_descriptor() - * - * \returns LIBUSB_SUCCESS on success - * \returns LIBUSB_ERROR code on error - */ -int LIBUSB_CALL libusb_parse_bos_descriptor(const void *buf, int len, - struct libusb_bos_descriptor **bos); - -/** \ingroup desc - * Free a Binary Object Store (BOS) descriptor. - * - * \param[in] bos the descriptor to free - */ -void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos); - /** \ingroup hotplug * Callback handle. * @@ -1679,11 +1832,16 @@ void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos); * per libusb_context and it is safe to call libusb_hotplug_deregister_callback() * on an already deregisted callback. * + * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 + * * For more information, see \ref hotplug. */ typedef int libusb_hotplug_callback_handle; /** \ingroup hotplug + * + * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 + * * Flags for hotplug events */ typedef enum { /** Arm the callback and fire it for all matching currently attached devices. */ @@ -1691,6 +1849,9 @@ typedef enum { } libusb_hotplug_flag; /** \ingroup hotplug + * + * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 + * * Hotplug events */ typedef enum { /** A device has been plugged in and is ready to use */ @@ -1719,7 +1880,9 @@ typedef enum { * It is safe to call either libusb_hotplug_register_callback() or * libusb_hotplug_deregister_callback() from within a callback function. * - * \param libusb_context context of this notification + * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 + * + * \param ctx context of this notification * \param device libusb_device this event occurred on * \param event event that occurred * \param user_data user data provided when this callback was registered @@ -1727,9 +1890,9 @@ typedef enum { * returning 1 will cause this callback to be deregistered */ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx, - libusb_device *device, - libusb_hotplug_event event, - void *user_data); + libusb_device *device, + libusb_hotplug_event event, + void *user_data); /** \ingroup hotplug * Register a hotplug callback function @@ -1739,6 +1902,20 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx, * armed until either it is deregistered with libusb_hotplug_deregister_callback() * or the supplied callback returns 1 to indicate it is finished processing events. * + * If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be + * called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices + * already plugged into the machine. Note that libusb modifies its internal + * device list from a separate thread, while calling hotplug callbacks from + * libusb_handle_events(), so it is possible for a device to already be present + * on, or removed from, its internal device list, while the hotplug callbacks + * still need to be dispatched. This means that when using \ref + * LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arrival + * of the same device, once from libusb_hotplug_register_callback() and once + * from libusb_handle_events(); and/or your callback may be called for the + * removal of a device for which an arrived call was never made. + * + * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 + * * \param[in] ctx context to register this callback with * \param[in] events bitwise or of events that will trigger this callback. See \ref * libusb_hotplug_event @@ -1752,13 +1929,13 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx, * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure */ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx, - libusb_hotplug_event events, - libusb_hotplug_flag flags, - int vendor_id, int product_id, - int dev_class, - libusb_hotplug_callback_fn cb_fn, - void *user_data, - libusb_hotplug_callback_handle *handle); + libusb_hotplug_event events, + libusb_hotplug_flag flags, + int vendor_id, int product_id, + int dev_class, + libusb_hotplug_callback_fn cb_fn, + void *user_data, + libusb_hotplug_callback_handle *handle); /** \ingroup hotplug * Deregisters a hotplug callback. @@ -1766,11 +1943,13 @@ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx, * Deregister a callback from a libusb_context. This function is safe to call from within * a hotplug callback. * + * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 + * * \param[in] ctx context this callback is registered with * \param[in] handle the handle of the callback to deregister */ void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx, - libusb_hotplug_callback_handle handle); + libusb_hotplug_callback_handle handle); #ifdef __cplusplus } diff --git a/cgminer/lib/libjansson.a b/cgminer/lib/libjansson.a index 9891684..555c241 100644 Binary files a/cgminer/lib/libjansson.a and b/cgminer/lib/libjansson.a differ diff --git a/cgminer/lib/libusb-1.0.0.dylib b/cgminer/lib/libusb-1.0.0.dylib new file mode 100755 index 0000000..2a1425e Binary files /dev/null and b/cgminer/lib/libusb-1.0.0.dylib differ diff --git a/cgminer/lib/libusb-1.0.2.dylib b/cgminer/lib/libusb-1.0.2.dylib index af1ba3f..d44ba7b 100755 Binary files a/cgminer/lib/libusb-1.0.2.dylib and b/cgminer/lib/libusb-1.0.2.dylib differ diff --git a/cgminer/lib/libusb-1.0.a b/cgminer/lib/libusb-1.0.a index 2449d0d..1cff48c 100644 Binary files a/cgminer/lib/libusb-1.0.a and b/cgminer/lib/libusb-1.0.a differ diff --git a/cgminer/lib/libusb-1.0.dylib b/cgminer/lib/libusb-1.0.dylib index d6874bc..a844670 120000 --- a/cgminer/lib/libusb-1.0.dylib +++ b/cgminer/lib/libusb-1.0.dylib @@ -1 +1 @@ -libusb-1.0.2.dylib \ No newline at end of file +libusb-1.0.0.dylib \ No newline at end of file diff --git a/cgminer/lib/libusb-1.0.la b/cgminer/lib/libusb-1.0.la index 5f2aab3..5a37f29 100755 --- a/cgminer/lib/libusb-1.0.la +++ b/cgminer/lib/libusb-1.0.la @@ -5,10 +5,10 @@ # It is necessary for linking the library. # The name that we can dlopen(3). -dlname='libusb-1.0.2.dylib' +dlname='libusb-1.0.0.dylib' # Names of this library. -library_names='libusb-1.0.2.dylib libusb-1.0.dylib' +library_names='libusb-1.0.0.dylib libusb-1.0.dylib' # The name of the static archive. old_library='libusb-1.0.a' @@ -23,8 +23,8 @@ dependency_libs=' -lobjc' weak_library_names='' # Version information for libusb-1.0. -current=2 -age=0 +current=1 +age=1 revision=0 # Is this an already installed library? diff --git a/cgminer/lib/pkgconfig/libusb-1.0.pc b/cgminer/lib/pkgconfig/libusb-1.0.pc index 8c09ac7..8db09c0 100644 --- a/cgminer/lib/pkgconfig/libusb-1.0.pc +++ b/cgminer/lib/pkgconfig/libusb-1.0.pc @@ -4,9 +4,8 @@ libdir=${exec_prefix}/lib includedir=${prefix}/include Name: libusb-1.0 -Description: C API for USB device access from Linux, Mac OS X, OpenBSD, NetBSD and Windows userspace -Version: 1.0.16-rc10 +Description: C API for USB device access from Linux, Mac OS X, Windows and OpenBSD/NetBSD userspace +Version: 1.0.18 Libs: -L${libdir} -lusb-1.0 Libs.private: -lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation Cflags: -I${includedir}/libusb-1.0 -