Read from ttyUSB0 in own thread
You have two bugs.
First, this code:
result = read(conHandler, &buffer, size);
You read into the place where the address of buffer is stored rather than the buffer itself.
Second, you throw the results of read
away, so you have no idea how many bytes you read. If the code is intended to read exactly size
bytes, you need to do something like this:
int total_read = 0;
do
{
result = read(conHandle, buffer + total_read, size - total_read);
if (result <= 0) return result;
total_read += result;
}
while (total_read < result);
Why my CGI Script can't access to ttyUSB0?
The command below solved my problem :
sudo adduser www-data dialout
Kill process that raises Device or resource busy: '/dev/ttyUSB0'?
You can use
$ fuser /dev/ttyUSB0
to list the PIDs of the processes using the file. Alternatively, if your fuser
command supports it you can use the -k
option to kill them.
Related Topics
How to Configure Gitlab as a Subdomain in Nginix.Conf
Bridge Serial-Ports Over Network
Awk, Pipe and Tail -F Giving Unexpected Behavior
Raising Hard Limit on Rlimit_Nofile System-Wide on Linux
Need Explanation on Pri Standard Format Specifier for Ps - Possible Bug in Documentation
Diff Files Comparing Only First N Characters of Each Line
How to Get Groupname When I Have The Groupid
Terminal "Png" Missing When Using Gnuplot
How to Run Jprofiler from Windows Machine to Remote Linux Jvm
How to Sort Numbers in a Qtreewidget Column
Setting Environment Variable with Leading Digit in Bash
Prevent Fork() from Copying Sockets
Is There Any Posix Way Through Fstat() to Check Whether a File Is a Symbolic Link or Not
Write and Read from Ttyusb0, Can't Get Response
How to Add My Scheduler to Linux Kernel
Cross-Compilation to X86_64-Unknown-Linux-Gnu Fails on MAC Osx