@@ -89,7 +89,7 @@
Loading
89 89
    ~this() { close(); }
90 90
91 91
    /// Close handle
92 -
    void close() @nogc
92 +
    void close()
93 93
    {
94 94
        if (closed) return;
95 95
        closeHandle(_handle);
@@ -513,6 +513,7 @@
Loading
513 513
            opt.c_oflag &= ~OPOST;
514 514
            opt.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
515 515
            opt.c_cflag &= ~(CSIZE | PARENB);
516 +
516 517
            opt.c_cc[VMIN] = 0;
517 518
            opt.c_cc[VTIME] = 0;
518 519
@@ -800,7 +801,7 @@
Loading
800 801
            ReadException if read error occurs
801 802
            TimeoutException if timeout expires
802 803
     +/
803 -
    abstract void[] read(void[] buf, CanRead cr=CanRead.allOrNothing) @nogc;
804 +
    abstract void[] read(void[] buf, CanRead cr=CanRead.allOrNothing) /+ @nogc +/;
804 805
805 806
    ///
806 807
    protected void checkAbility(CanRead cr, size_t readed, size_t buffer) @nogc
@@ -827,5 +828,5 @@
Loading
827 828
            WriteException if read error occurs
828 829
            TimeoutException if timeout expires
829 830
     +/
830 -
    abstract void write(const(void[]) buf) @nogc;
831 +
    abstract void write(const(void[]) buf) /+ @nogc +/;
831 832
}

@@ -0,0 +1,122 @@
Loading
1 +
module serialport.evloopready;
2 +
3 +
import serialport.base;
4 +
5 +
/++ Serial Port Event Loop Ready
6 +
 +/
7 +
class SerialPortEL : SerialPort
8 +
{
9 +
protected:
10 +
    EvLoopHook evloop;
11 +
12 +
public:
13 +
14 +
    interface EvLoopHook
15 +
    {
16 +
        void beforeCloseHandle(SPHandle);
17 +
        void afterOpenHandle(SPHandle);
18 +
19 +
        void wakeOnRead(bool, Duration tm=Duration.zero);
20 +
        void wakeOnWrite(bool, Duration tm=Duration.zero);
21 +
22 +
        void wait();
23 +
    }
24 +
25 +
    ///
26 +
    this(EvLoopHook e, string exmode)
27 +
    {
28 +
        evloop = enforce(e, "event loop hook is null");
29 +
        super(exmode);
30 +
    }
31 +
32 +
    ///
33 +
    this(EvLoopHook e, string port, string mode)
34 +
    {
35 +
        evloop = enforce(e, "event loop hook is null");
36 +
        super(port, Config.parse(mode));
37 +
    }
38 +
39 +
    ///
40 +
    this(EvLoopHook e, string port, uint baudRate)
41 +
    {
42 +
        evloop = enforce(e, "event loop hook is null");
43 +
        super(port, Config(baudRate));
44 +
    }
45 +
46 +
    ///
47 +
    this(EvLoopHook e, string port, uint baudRate, string mode)
48 +
    {
49 +
        evloop = enforce(e, "event loop hook is null");
50 +
        super(port, Config(baudRate).set(mode));
51 +
    }
52 +
53 +
    ///
54 +
    this(EvLoopHook e, string port, Config conf)
55 +
    {
56 +
        evloop = enforce(e, "event loop hook is null");
57 +
        super(port, conf);
58 +
    }
59 +
60 +
    override void close()
61 +
    {
62 +
        if (closed) return;
63 +
        evloop.beforeCloseHandle(_handle);
64 +
        closeHandle(_handle);
65 +
        _handle = initHandle;
66 +
    }
67 +
68 +
    override void reopen(string np, Config cfg)
69 +
    {
70 +
        super.reopen(np, cfg);
71 +
        evloop.afterOpenHandle(_handle);
72 +
    }
73 +
74 +
    override void[] read(void[] buf, CanRead cr=CanRead.allOrNothing)
75 +
    {
76 +
        if (closed) throwPortClosedException(port);
77 +
78 +
        size_t res;
79 +
        const timeout = buf.length * readTimeoutMult + readTimeout;
80 +
        const sw = StopWatch(AutoStart.yes);
81 +
82 +
        evloop.wakeOnRead(true, timeout);
83 +
        scope (exit) evloop.wakeOnRead(false);
84 +
85 +
        import std.stdio;
86 +
        while (sw.peek < timeout)
87 +
        {
88 +
            res += m_read(buf[res..$]).length;
89 +
            if (res == buf.length) return buf[];
90 +
91 +
            evloop.wait();
92 +
            stderr.writeln("WAKEUP IN SERIALPORT.READ !!!!!!!!!");
93 +
        }
94 +
        stderr.writeln("TIMEOUT !!!!!!!!!");
95 +
96 +
        checkAbility(cr, res, buf.length);
97 +
98 +
        return buf[0..res];
99 +
    }
100 +
101 +
    override void write(const(void[]) arr)
102 +
    {
103 +
        if (closed) throwPortClosedException(port);
104 +
105 +
        size_t written;
106 +
        const timeout = arr.length * writeTimeoutMult + writeTimeout;
107 +
        const sw = StopWatch(AutoStart.yes);
108 +
109 +
        evloop.wakeOnWrite(true, timeout);
110 +
        scope (exit) evloop.wakeOnWrite(false);
111 +
112 +
        while (sw.peek < timeout)
113 +
        {
114 +
            written += m_write(arr[written..$]);
115 +
            if (written == arr.length) return;
116 +
117 +
            evloop.wait();
118 +
        }
119 +
120 +
        throwTimeoutException(port, "write timeout");
121 +
    }
122 +
}

@@ -131,7 +131,7 @@
Loading
131 131
        if (isSomeFunction!F && (functionAttributes!F & FunctionAttribute.nogc))
132 132
    { sleepFunc = sf; super(port, conf); }
133 133
134 -
    override void[] read(void[] buf, CanRead cr=CanRead.allOrNothing)
134 +
    override void[] read(void[] buf, CanRead cr=CanRead.allOrNothing) @nogc
135 135
    {
136 136
        if (closed) throwPortClosedException(port);
137 137
@@ -151,7 +151,7 @@
Loading
151 151
        return buf[0..res];
152 152
    }
153 153
154 -
    override void write(const(void[]) arr)
154 +
    override void write(const(void[]) arr) @nogc
155 155
    {
156 156
        if (closed) throwPortClosedException(port);
157 157
@@ -214,7 +214,7 @@
Loading
214 214
     +/
215 215
    void[] readContinues(void[] buf, Duration startTimeout=1.seconds,
216 216
                                     Duration frameGap=50.msecs,
217 -
                                     bool expectAnything=true)
217 +
                                     bool expectAnything=true) @nogc
218 218
    {
219 219
        if (closed) throwPortClosedException(port);
220 220

@@ -32,6 +32,10 @@
Loading
32 32
class TimeoutException : SerialPortException
33 33
{ private this() @safe pure nothrow @nogc { super(); } }
34 34
35 +
///
36 +
class NullEvLoopException : SerialPortException
37 +
{ private this() @safe pure nothrow @nogc { super(); } }
38 +
35 39
///
36 40
class SysCallException : SerialPortException
37 41
{
@@ -161,6 +165,7 @@
Loading
161 165
            preallocSerialPortException,
162 166
            preallocPortClosedException,
163 167
            preallocTimeoutException,
168 +
            preallocNullEvLoopException,
164 169
            preallocSysCallException,
165 170
            preallocReadException,
166 171
            preallocWriteException,
@@ -174,6 +179,7 @@
Loading
174 179
mixin throwSPEMix!SerialPortException;
175 180
mixin throwSPEMix!PortClosedException;
176 181
mixin throwSPEMix!TimeoutException;
182 +
mixin throwSPEMix!NullEvLoopException;
177 183
178 184
mixin throwSPSCEMix!SysCallException;
179 185
mixin throwSPSCEMix!ReadException;
Files Coverage
source/serialport 83.01%
Project Totals (9 files) 83.01%
104.3
TRAVIS_OS_NAME=linux
104.1
TRAVIS_OS_NAME=linux
104.8
TRAVIS_OS_NAME=linux
104.5
TRAVIS_OS_NAME=linux
104.7
TRAVIS_OS_NAME=linux
104.10
TRAVIS_OS_NAME=linux
104.11
TRAVIS_OS_NAME=linux
104.14
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading