GithubHelp home page GithubHelp logo

ncrashed / serial-port Goto Github PK

View Code? Open in Web Editor NEW
22.0 5.0 7.0 739 KB

Crossplatform library for operating with serial ports in D programming language.

License: Boost Software License 1.0

D 96.24% Makefile 3.76%

serial-port's Introduction

serial-port

Crossplatform library for operating with serial ports in D programming language. Documentation.

Compilation

With dub:

dub build

with make

make

Or, put in your dub.json dependencies:

"dependencies": {
  "serial-port": "~>1.2"
},

To compile tests with dub:

dub build --build=unittest --config=unittest
./serial-port

with make

make test
./serial-port

You should have two serial ports linked to each other (com0com on Windows, socat in linux). For instance, writing to 'COM1' and reading from 'COM2'. On posix you can use socat to create serial port pipe:

socat /dev/ttyS0,raw,echo=0,crnl /dev/ttyS1,raw,echo=0,crnl

References

serial-port's People

Contributors

o3o avatar redstar avatar rlonstein avatar

Stargazers

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

serial-port's Issues

Cleanup grammar in exceptions

Here's one:

  • Timeout is expires for serial port ... FIXED: Timeout is expired for serial port ...

I didn't find any others in a quick scan that I did.

serial-port-master dub upgrade problem

Dub raises an error when I try to upgrade:

$ dub upgrade
Error executing command upgrade: Untracked file found, aborting package removal: /home/o3o/.dub/packages/serial-port-master/.dub

How to send ubyte data trough the serial port.

Hello,

I am trying to send some byte data to /dev/ttyUSB0

  auto com = new SerialPort("/dev/ttyUSB0");

  ubyte byt1 = 0xFF;
  ubyte byt2 = 0xeF;

  com.write(cast(void[])byt1);
  com.write(cast(void[])byt1);

This gives me Error: cannot cast byt1 of type ubyte to void[]

Also, how do I set the baud rate to 9600 ? I know there is an emun BaudRaute, but how to use it its not dead obvious.

write is not callable

it gives me this error when I try to use the function Write:

Error: function serial.device.SerialPort.write(const(void[]) arr) is not callable using argument types (immutable(char)*)

obviously the constant Void[] is not a valid type, perhaps you meant char[] instead?

Linux GDC compile fails with undefined identifier

Building serial-port 1.1.0+commit.4.gf036724 configuration "library", build type debug.
Running gdc...
source/serial/device.d:1014: error: undefined identifier B57600, did you mean variable B576000?
source/serial/device.d:1092: error: undefined identifier B57600, did you mean variable B576000?

Looking at the source, it seems the mac os x platform definition does the right thing. Do that for Linux.

std.array.split cannot deduce function from argument types when compiled with gdc + linux

../../../../../../../../home/dkords/.dub/packages/serial-port-1.1.0/source/serial/device.d:922: error: template std.array.split cannot deduce function from argument types !("msecs")(Duration), candidates are:
/mnt/lotsostuff/dev/tools/x86_64-gdcproject-linux-gnu/include/d/4.9.0/std/array.d:1358: note: std.array.split(S)(S s) if (isSomeString!S)
/mnt/lotsostuff/dev/tools/x86_64-gdcproject-linux-gnu/include/d/4.9.0/std/array.d:1438: note: std.array.split(R, E)(R r, E delim) if (isForwardRange!R && is(typeof(ElementType!R.init == E.init)))
/mnt/lotsostuff/dev/tools/x86_64-gdcproject-linux-gnu/include/d/4.9.0/std/array.d:1448: note: std.array.split(R1, R2)(R1 r, R2 delim) if (isForwardRange!R1 && isForwardRange!R2 && is(typeof(ElementType!R1.init == ElementType!R2.init)))
/mnt/lotsostuff/dev/tools/x86_64-gdcproject-linux-gnu/include/d/4.9.0/std/array.d:1459: note: std.array.split(alias isTerminator, R)(R r) if (isForwardRange!R && is(typeof(unaryFun!isTerminator(r.front))))
FAIL ../../../../../../../../home/dkords/.dub/packages/serial-port-1.1.0/.dub/build/library-debug-linux.posix-x86_64-gdc_2065-0CC4EDDA44197C04B68AE88DAC1E1B69/ serial-port staticLibrary
Error executing command run: gdc failed with exit code 1.

How can i read all the serial buffer

Hi,
I'm trying to read all the content of the serial port.
However I don't know the message length which could be variable.

Using a large array like ubyte[2048], the serial device throws a serial.device.TimeoutException.
Thank you very much for your efforts!

compiler error with the latest dmd compiler

../../.dub/packages/serial-port-1.1.0/source/serial/device.d(985,56): Error: undefined identifier 'speed_t', did you mean function 'speed'?
../../.dub/packages/serial-port-1.1.0/source/serial/device.d(1002,21): Error: undefined identifier 'speed_t', did you mean function 'speed'?
../../.dub/packages/serial-port-1.1.0/source/serial/device.d(1035,18): Error: undefined identifier 'termios'

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.