TestsTested | ✗ |
LangLanguage | CC |
License | Custom |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
This is an Objective-C wrapper class for the libmodbus library. The wrapper is free to use for anyone (GNU Lesser Public License).
The wrapper only supports TCP for now. It does not wrap all of the libmodbus functions. I recommend reading th elibmodbus documentation if you are missing some features. Chances are libmodbus already supports it! If you modify or extend the code, please contribute back!
Drag ObjectiveLibModbus.h and ObjectiveLibModbus.m into you're project.
Import ObjectiveLibModbus where you will be using it:
#import "ObjectiveLibModbus.h"
//Allocate a new ObjectiveLibModbus instance
objLibModbus = [[ObjectiveLibModbus alloc] initWithTCP:@"192.168.2.10" port:502 device:1];
[objLibModbus connect:^{
//connected and ready to do modbus calls
} failure:^(NSError *error) {
//Handle error
NSLog(@"Error: %@", error.localizedDescription);
}];
[objLibModbus readRegistersFrom:1000 count:5 success:^(NSArray *array) {
//Do something with the returned data (NSArray of NSNumber)..
NSLog(@"Array: %@", array);
} failure:^(NSError *error) {
//Handle error
NSLog(@"Error: %@", error.localizedDescription);
}];
[objLibModbus disconnect];