Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iUtvikler/ObjectiveLibModbus
Objective-C wrapper for the libmodbus library (http://libmodbus.org/)
https://github.com/iUtvikler/ObjectiveLibModbus
Last synced: 3 days ago
JSON representation
Objective-C wrapper for the libmodbus library (http://libmodbus.org/)
- Host: GitHub
- URL: https://github.com/iUtvikler/ObjectiveLibModbus
- Owner: LarsJK
- Archived: true
- Created: 2012-04-28T10:55:20.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2022-11-22T10:57:59.000Z (almost 2 years ago)
- Last Synced: 2024-04-10T05:28:10.563Z (7 months ago)
- Language: Objective-C
- Size: 154 KB
- Stars: 37
- Watchers: 4
- Forks: 28
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NOTE!
This project has been abandoned.
I started work on a swift wrapper for libmodbus ([example](https://github.com/LarsJK/libmodbus-swift-example), [library](https://github.com/LarsJK/libmodbus-swift), [system-module](https://github.com/LarsJK/Clibmodbus)), and there is a new Swift fork [ktsakaguchi/SwiftLibModbus](https://github.com/ktsakaguchi/SwiftLibModbus). I recommend using that instead!
# ObjectiveLibModbus
This is an Objective-C wrapper class for the [*libmodbus library*](http://libmodbus.org). 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 the libmodbus documentation if you are missing some features. Chances are libmodbus already supports it! If you modify or extend the code, please contribute back!
## How To Get Started
The easiest way to get this working is to use [*CocoaPods*](http://cocoapods.org/)
If you dont use CocoaPods do this:
- Drag all the .c and .h files from the Vendor/libmodbus folder into you're project.
- Drag ObjectiveLibModbus.h and ObjectiveLibModbus.m into you're project from ObjectiveLibModbus folder.Now that you're set up, do the following to make modbus calls
- Import ObjectiveLibModbus where you will be using it:
``` objective-c
#import "ObjectiveLibModbus.h"
```- Now make a new instance of ObjectiveLibModbus and connect:
``` objective-c
//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);
}];
```- Make a modbus call:
``` objective-c
[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);
}];
```- Disconnect when you are finished with you’re modbus calls:
``` objective-c
[objLibModbus disconnect];
```