digitalmars.D.learn - SerialPort
- braboar (14/15) Sep 20 2018 I am going to play with serial port read/write, so I fetched
- Vladimir Panteleev (5/6) Sep 21 2018 Here's a program I wrote (after lots of trial-and-error) to
- dangbinghoo (37/52) Sep 23 2018 here is my code really works:
- UlanReed (5/5) Jan 11 2019 For me
I am going to play with serial port read/write, so I fetched
serial-port. After that, I wrote simple program:
auto port_name = "/dev/ttyUSB1";
auto reader = new SerialPort(port_name);
reader.dataBits(DataBits.data8);
reader.stopBits(StopBits.one);
reader.parity(Parity.none);
reader.speed(BaudRate.BR_230400);
string[] income;
reader.read(income);
and the result is
serial.device.TimeoutException
Can anybody give me a guide of using serial port?
And one more question: how to outline code blocks? ''' or ---
can't help me.
Sep 20 2018
On Thursday, 20 September 2018 at 10:51:52 UTC, braboar wrote:Can anybody give me a guide of using serial port?Here's a program I wrote (after lots of trial-and-error) to control my monitor through an USB serial-port adapter: https://github.com/CyberShadow/misc/blob/master/pq321q.d Hope this helps.
Sep 21 2018
On Thursday, 20 September 2018 at 10:51:52 UTC, braboar wrote:
I am going to play with serial port read/write, so I fetched
serial-port. After that, I wrote simple program:
auto port_name = "/dev/ttyUSB1";
auto reader = new SerialPort(port_name);
reader.dataBits(DataBits.data8);
reader.stopBits(StopBits.one);
reader.parity(Parity.none);
reader.speed(BaudRate.BR_230400);
string[] income;
reader.read(income);
and the result is
serial.device.TimeoutException
Can anybody give me a guide of using serial port?
And one more question: how to outline code blocks? ''' or ---
can't help me.
here is my code really works:
com is `reader` object in your code.
```
void writeBytes(ubyte[] arr)
{
com.write(arr);
}
void serialThread()
{
ubyte[500] buff;
running = true;
while (running)
{
string str;
size_t readed;
try
{
readed = com.read(buff);
// if (readed > 0) {
//writeln("com port readed " ~
std.conv.to!string(readed));
str = cast(string)(buff[0 .. readed]).idup;
// Don't use writeln for console or string serail
application.
write(str);
// }
}
// must catch for continous reading, otherwize, com
port will block.
catch (TimeoutException e)
{
}
}
}
```
thanks!
Sep 23 2018
For me https://www.virtual-serial-port.org/products/serialmonitor/ is an ideal way to track down problems that may occur during application or driver development, testing and optimization of serial devices and i use this soft all time.
Jan 11 2019









Vladimir Panteleev <thecybershadow.lists gmail.com> 