GithubHelp home page GithubHelp logo

green-mod / bacnet-stack-rs Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 1.06 MB

๐Ÿฆ€ Rust wrapper for a famous BACnet Protocol Stack library in C

C 10.91% Rust 89.09%
bacnet bindgen-wrapper rust cmake

bacnet-stack-rs's Introduction

bacnet-stack-rs

This library is a Rust wrapper for the BACnet Stack project, built with bindgen, cmake, and love ๐Ÿ’š.

The folder bacnet-sys/bacnet-stack contains the submodule of the original C library.

Also, this repository is kind of a fork of this other one, updated to the latest version of Rust and bacnet-stack.

Updating the stack

To update the stack, you need to update the submodule bacnet-stack to the latest commit, always check if cargo can still build the project, with cargo build, and then run cargo test to check if the tests are still passing.

bacnet-stack-rs's People

Contributors

giorgiobertolotti avatar

Stargazers

 avatar

Watchers

 avatar  avatar

bacnet-stack-rs's Issues

BACnet server app

Hi can you make a BACnet server app from this? This code below doesn't work but curious if it would be hard putting something together like did with the BACnet client apps in rust? The idea would be to just make one AnalogValue point with a fake temperature sensor reading. I dont know enough on the C stack to complete it curious if you had any ideas?

#include "bacnet/basic/sys/mstimer.h"

#include "bacnet/datalink/bip.h"
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/object/av.h"
#include "bacnet/datalink/bip.h"


static struct mstimer Update_Timer;
static float space_temperature = 24.5;

void Analog_Value_Init(void) {
    static bool initialized = false;
    if (!initialized) {
        initialized = true;
        Analog_Value_Create(0); // Instance 0
        Analog_Value_Units_Set(0, UNITS_DEGREES_CELSIUS);
        Analog_Value_Present_Value_Set(0, space_temperature, 10);
    }
}

void Update_Analog_Value(void) {
    mstimer_reset(&Update_Timer);
    space_temperature += 0.1;  // Update the temperature for simulation
    Analog_Value_Present_Value_Set(0, space_temperature, 10);
}

int main(void) {
    BACNET_ADDRESS src = {0};  // source address

    Device_Set_Object_Instance_Number(12345); // Set device instance number
    bip_init(NULL);  // BACnet/IP initialization
    Analog_Value_Init();  // Initialize the Analog Value object

    mstimer_set(&Update_Timer, 1000);  // 1 second timer

    while (1) {
        bip_network_layer_task();  // BACnet tasks
        if (mstimer_expired(&Update_Timer)) {
            Update_Analog_Value();
        }
    }
    return 0;
}

And a Makefile???

BACNET_SRC_DIR = $(realpath ../../src)
BACNET_LIB_DIR = $(realpath ../../lib)

CC = gcc
#CFLAGS = -I$(BACNET_SRC_DIR) -std=gnu99
CFLAGS = -I$(BACNET_SRC_DIR) -std=gnu99 -Wall -Wextra

LFLAGS = -L$(BACNET_LIB_DIR) -lbacnet

TARGET = simple_server

# Include all necessary C source files
SRC = main.c \
      $(BACNET_SRC_DIR)/bacnet/basic/object/av.c \
      $(BACNET_SRC_DIR)/bacnet/basic/sys/mstimer.c \
      $(BACNET_SRC_DIR)/bacnet/datalink/bip.c \
      $(BACNET_SRC_DIR)/bacnet/basic/object/device.c \
      $(BACNET_SRC_DIR)/bacnet/basic/sys/sfilename.c \
      $(BACNET_SRC_DIR)/bacnet/basic/sys/sbuf.c

OBJS = $(SRC:.c=.o)

all: $(TARGET)

$(TARGET): $(OBJS)
    $(CC) $(OBJS) $(LFLAGS) -o $@

.c.o:
    $(CC) -c $(CFLAGS) $< -o $@

clean:
    rm -f $(OBJS) $(TARGET)

.PHONY: all clean

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.