GithubHelp home page GithubHelp logo

luka8911 / objectivelibmodbus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from larsjk/objectivelibmodbus

0.0 0.0 1.0 174 KB

Objective-C wrapper for the libmodbus library (http://libmodbus.org/)

Ruby 4.73% Objective-C 95.27%

objectivelibmodbus's Introduction

NOTE!

This project has been abandoned.

I started work on a swift wrapper for libmodbus (example, library, system-module), and there is a new Swift fork ktsakaguchi/SwiftLibModbus. I recommend using that instead!

ObjectiveLibModbus

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 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

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:
#import "ObjectiveLibModbus.h"
  • Now make a new instance of ObjectiveLibModbus and connect:
//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:
[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:
[objLibModbus disconnect];

objectivelibmodbus's People

Contributors

larsjk avatar luka8821 avatar

Forkers

hypercrypt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.