Giter Site home page Giter Site logo

dart_periphery's People

Contributors

albandurrheimer avatar ookami-kb avatar pezi avatar uliprantz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dart_periphery's Issues

Error Using dart_periphery (flutter-pi)

Hi, I am running flutter pi on an RPI 3B. When i use the flutter_gpiod package, it works well and i can access the GPIOs but when i try using dart_periphery and test a basic I2C function, i get an error as below. I dont know what is the issue or what to check.

Code:
var i2c = I2C(1);
try {
print('I2C info:' + i2c.getI2Cinfo());
} finally {
i2c.dispose();
}

Error:
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following ArgumentError was thrown building MyHomePage(dirty, state: _MyHomePageState#9daba):
flutter: Invalid argument(s): join(null, "src", "native", "dart_periphery_32.1.0.0.so"): part 0 was null, but
flutter: part 1 was not.

Unhandled exception when using Docker container

Hi. When launching an application from a Docker container, I get an exception.

Raspberry Pi 3 Model B Rev 1.2

led.dart file for example:

import 'dart:io';
import 'package:dart_periphery/dart_periphery.dart';

void main() {
  setCPUarchitecture(CPU_ARCHITECTURE.arm64);
  setCustomLibrary('/ex/libperiphery_arm64.so');

  GPIO gpioOut = GPIO(18, GPIOdirection.gpioDirOut);
  
  for (var i = 0; i < 10; ++i) {
    gpioOut.write(true);
    sleep(Duration(seconds: 1));
    gpioOut.write(false);
    sleep(Duration(seconds: 1));
  }
  
  gpioOut.dispose();
}

I add a file to the project libperiphery_arm64.so to then copy it to the Docker image.

Creating a Dockerfile:

FROM dart:stable AS build

WORKDIR /ex

COPY pubspec.* ./
COPY libperiphery_arm64.so .

RUN dart pub get

COPY . .

RUN dart pub get --offline

RUN dart compile exe bin/led.dart -o bin/blink

CMD ["/ex/bin/blink"]

Creating an image:

docker build -t led .

Launching the container:

docker run -it --rm led

As a result, I get an exception:

изображение

Thank you for your help

I2C for PCF8591 A/D - I might be able to Help

Hi, great work on the package. I am a Flutter app developer but my previous experiences are in embedded systems such as the STM32 running RTOS and coded in C.

Currently I am using your package to create embedded systems leveraging Flutter for the UI on touch screens on Raspberry Pi 4B.

After reviewing your code it seems that you are creating IC specific .dart files that are part of your package.

I may be oversimplifying your code but it seems that the secret sauce is the IC specific files for a particular I2C IC and that more devices can be added if these dart files were developed.

Currently I did not see any A/D IC with I2C in the package and that is a must for embedded Supervisory Control and Data Acquisition (SCADA) systems that I work with. I might be able to help and I can also test on various SBC and give you the results.

Let me know if I can help - [email protected] or https://www.linkedin.com/in/bob-taylor-mscs-mba/

Receive data continuously / listen for incoming data for Serial

Hi I'm trying to use this library to receive data from serial (raspberry)
how can i listen to incoming data? does it use poll data inside a timer like this?

timer = Timer.periodic(const Duration(milliseconds: 100), (timer) {
      var poll = s.poll(0);
      if (poll) {
        var event = s.read(256, 100);
        print('payload = $event');
        payload.add(event.toString());
        _controller.animateTo(
          _controller.position.maxScrollExtent,
          duration: const Duration(milliseconds: 100),
          curve: Curves.fastOutSlowIn,
        );
        setState(() {});
});

is using a timer like this good ? or is there another more efficient way?

Thank you for your help

Can't read more than one byte at time from Serial

Hi, I'm trying to use this library for various I/O in my project, but im struggling to read serial data of arbitrary length.

If I run this code in a periodic timer:

SerialReadEvent sre = serial.read(100, 0);
if (sre.count > 0) {
  print("serial has data ${sre.count}");
}

I can never read more than one byte at a time, despite sending multiple. Also the byte value doesn't match any of the sent values.
My system is based on a RPI CM4 running flutter-pi and I have dtoverlay=midi-uart0 enabled in the config (mapping 38400bps to 31200 for MIDI).

Any clues as to what is causing this or a good working example?

I2C send word error

This is a neat library. Big thanks for developing it! Hope to see it get back to active life some day.

I think there is an issue when sending words via i2c.
Functions writeWord/writeWordReg

void writeWord(int address, int wordValue,

void writeWordReg(int address, int register, int wordValue,

use the following code to split bytes and send them separately.
array = [wordValue | 0xff, wordValue >> 8];
The high byte gets sent ok, however the low byte gets OR'ed with 0xff, so 0xff always gets sent.
I believe it should be & 0xff.

Unhandled Exception: dart_periphery is only supported for Linux!

I tried to use this library and ran it's serial example to build an application for windows but got following log in the console with errors:
Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Debug service listening on ws://127.0.0.1:58318/q5IEvw4shNs=/ws
Syncing files to device Windows...
flutter: Serial test - COZIR CO2 Sensor
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: dart_periphery is only supported for Linux!
#0 getPeripheryLib (package:dart_periphery/src/library.dart:173:5)
#1 _peripheryLib (package:dart_periphery/src/signature.dart:12:38)
#2 _peripheryLib (package:dart_periphery/src/signature.dart)
#3 voidPtrVOIDM (package:dart_periphery/src/signature.dart:24:10)
#4 _nativeSerialNew (package:dart_periphery/src/serial.dart:143:26)
#5 _nativeSerialNew (package:dart_periphery/src/serial.dart)
#6 Serial._openSerial (package:dart_periphery/src/serial.dart:379:25)
#7 new Serial (package:dart_periphery/src/serial.dart:376:25)
#8 main (package:periserial/main.dart:9:11)
#9 _runMainZoned.. (dart:ui/hooks.dart:130:25)
#10 _rootRun (dart:async/zone.dart:1426:13)
#11 _CustomZone.run (dart:async/zone.dart:1328:19)
#12 _runZoned (dart:async/zone.dart:1861:10)
#13 runZonedGuarded (dart:async/zone.dart:1849:12)
#14 _runMainZoned. (dart:ui/hooks.dart:126:5)
#15 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:297:19)
#16 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

typo: useSharedLibray()

Should be useSharedLibrary(); (extra r), but I'm not just proposing a pull request as this will be a breaking change for anybody using the existing functionality. Perhaps the way to go initially is to add useSharedLibrary();, switch the documentation over to that, and deprecate useSharedLibray(); for when a more important breaking change comes along (e.g. Dart 3).

Question about sync API

Is there any specific reason why all the API is sync and waiting is implemented with sleep instead of await?

I'm using the library with flutter-pi and for some reason, it doesn't work great with isolates. The library calls sleep throughout the code, making UI laggy.

Can you add one-wire driver?

Nice contribution! Thanks!

Can you add one-wire driver?

I had used IO to simulate the time sequence, and the result is very unstable.

Please give me your precious advice!

Unidentified architecture

Hello,

Environment

  • Raspberry Pi 3 B
  • flutter-pi

Problem

When launch my program with dart_periphery, I have red screen with the message No pre-build c-periphery library for UNKNOWN available!.
I deduce that the integration of the system_info library in the librairy.so file fails to determine the AARCH64 architecture of my RPI.
I also notice that the system_info library is marked as discontinued.

SPI slave reading

Hi,

I'm trying to integrate an SPI connection to my flutter project, so I use a Raspberry Pi as master and an arduino as slave.
The arduino gets each byte of the request and returns a byte not related to the request (tested and working with another arduino as master).
When I try to communicate with my program, the arduino does retrieve the command sent, but in the result logged in the flutter project, it shows me the command sent and not the one the arduino is supposed to return.

My Flutter code:

      var spi = SPI(0, 0, SPImode.MODE0, 500000);
      try {
        print('SPI info:' + spi.getSPIinfo());
        var data = utf8.encode("Some data\r");
        var result = spi.transfer(data, false);
        var index = 0;
        for (var v in data) {
          print('Send $v->Answer ${result[index++]}');
        }
        print(utf8.decode(result));
      } catch (e) {
        print(e);
      } finally {
        spi.dispose();
      }

My Arduino code:

#include <SPI.h>
char buff [50];
char resp [50] = "Helo diti\r";
volatile byte indx;

void setup (void) {
  Serial.begin (9600);
  pinMode(MISO, OUTPUT); // have to send on master in so it set as output
  SPCR |= _BV(SPE); // turn on SPI in slave mode
  indx = 0; // buffer empty
  SPI.attachInterrupt(); // turn on interrupt
}
ISR (SPI_STC_vect)
{
  byte c = SPDR; // read byte from SPI Data Register

  if (indx < sizeof buff) {
    buff [indx] = c; // save data in the next index in the array buff
    SPDR = byte(resp[indx]);
    indx++;
    if (c == '\r') {
      Serial.println(buff);
      indx = 0; //reset button to zero
    }
  }
}

void loop (void) {
}

What is logged:

flutter: SPI info:SPI (fd=29, mode=0, max_speed=500000, bit_order=MSB_FIRST, bits_per_word=8, extra_flags=0x00000004)
flutter: Send 83->Answer 0
flutter: Send 111->Answer 83
flutter: Send 109->Answer 111
flutter: Send 101->Answer 109
flutter: Send 32->Answer 101
flutter: Send 100->Answer 32
flutter: Send 97->Answer 100
flutter: Send 116->Answer 97
flutter: Send 97->Answer 116
flutter: Send 13->Answer 97
flutter: Some data

Expected:

flutter: Send 83->Answer 0
flutter: Send 111->Answer 72
flutter: Send 109->Answer 101
flutter: Send 101->Answer 108
flutter: Send 32->Answer 111
flutter: Send 100->Answer 32
flutter: Send 97->Answer 100
flutter: Send 116->Answer 105
flutter: Send 97->Answer 116
flutter: Send 13->Answer 105
flutter: Helo diti

Returned with master Arduino:

Helo diti

Thank you for your help

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.