Programming :: C++ - LibSerial With Socat Virtual Serial Port?
Oct 17, 2010
I'm trying to use a C++ program to communicate through a serial port on Ubuntu 10.04. I've installed LibSerial and for now I'm using virtual serial ports using socat. I'm getting an error on compiling (found below). But step by step, first I start the virtual serial ports:
Code:
(MYNAME@MYCOMPUTER):~$ socat -d -d PTY: PTY:
2010/10/17 22:04:18 socat[18575] N PTY is /dev/pts/2
[code]....
View 4 Replies
ADVERTISEMENT
Mar 25, 2010
I'm currently working on a project for university that requires communication, via an RS232 link between a piece of hardware (I have designed and am currently testing) and some software(which need testing).
I was hoping to have my hardware finished by now so I could get on with testing the software over Easter.
The hardware does not work yet but I would still like to test the software.
Does any one know if there a way to make a virtual serial port that I could put data on and read data off while my program accesses it as a regular serial port so I can check my code?
I am using Ubuntu 9.10 and am happy to give any more information on request.
View 10 Replies
View Related
Mar 9, 2011
I want to create a virtual serial port in Fedora. I'm using Java code to communicate over a serial port. I want to test this code with out any serial devices connected.
View 1 Replies
View Related
Apr 15, 2010
can we use inb() and outb() functions for serial port programming ??
View 5 Replies
View Related
Sep 1, 2010
I'm using C serial in a program to open and use a serial port but the port won't open for one reason or another. The program successfully runs on a different computer and when using RealTerm: Serial Capture Program, I can connect through the serial port with the same settings as I'm attempting through my c code. Anyone have any idea why it might be failing? I know this is still pretty vague, so let me know if there's other things I can tell you that might help to finding a solution
View 3 Replies
View Related
May 5, 2010
I am trying to write some code that interfaces with an AVR over a serial port. Basically I send a command then read the output which is 6 bytes. I need to receive all 6 bytes before the program continues. Is there a way to do this? If I use read() it returns -1 unless I add a delay before reading the port. Is there a way to get it to read the 6 bytes as soon as they arrive?In python you simply say how many bytes you want and the max time you are willing to wait which seems a whole lot easier than read
View 1 Replies
View Related
Dec 21, 2010
I dont know if this is the right forum, But I try to find a solution, I want to intercept data from/to serial port without disrupting the software that manages the serial port, (I would like to save the data to a file or sent into a socket) I searched somes modules and programs (linspy, ttysniff, interceptty, maxty ...), A bit complicated (There are some diff. between kernel 2.4 and 2.6), So I'd like to change the serial port driver to intercept the "read" and "write " and do what I want with the data, I'd like to know what do you think about
View 3 Replies
View Related
Sep 15, 2010
I have an application written in C (by somebody else) monitoring a device connected to a serial port. I'm using an old laptop w. tinycore linux for an os. The app works well enough, and the communication speed is relatively slow, 9600bps, unidirectional, comes in packets of 18 bytes. The app is just picking apart the packets and displaying the contents on a formatted screen (ncurses), updating about once every 1/2 second. The trouble is, the app is polling the serial port and using *all* of the cpu bandwidth. The cpu fan runs full bore all the time.
Other activities are sluggish when the monitoring program is running. I'd like to modify the app to be a little more intelligent, use a receive buffer and interrupts to trigger processing each packet and, most importantly, not poll in a tight loop waiting for data. I'm not sure where to start, but I'm convinced this isn't that complicated of a change. Is there a good resource that would explain the basics of reading data from serial port software buffers, triggering on interrupts and suspending or sleeping when no interrupt is pending?
View 5 Replies
View Related
Oct 20, 2009
I am not a profession programmer. I have to write a C code which send some command to attach display using C program. Can any one please help me in this regard.
View 3 Replies
View Related
Mar 24, 2011
I'm attempting to write an application that needs to read and reply to messages that will appear via 3 different methods:
1) Standard serial communications
2) TCPIP over serial via PPP
3) TCPIP over Ethernet
The problem is that I'd like for the application to be able to receive packets from any and all of the three interfaces simultaneously. I shouldnt have much trouble with performing #1 and #3 at the same time, as I think I can just get a file descriptor from termios and another for a socket and then use select to wait for data. But #2 is problematic.
First I dont know how to set up a socket that uses PPP as the data link layer. And secondly, (here's the big one) this PPP data is coming over the same port that the serial data is. There's no chance for data collision, and I am guaranteed not to receive another packet until I respond to the last one (in the same protocol at that) but incoming packets may or may not be PPP/TCP/IP framed.
My app will act like the PPP client, so I was just thinking "somehow" that I could run a standard termios application on the serial port which would begin to interpret the packet. If its PPP framed then it would have to get passed to a PPP client, which would be listening to my application rather than a physical port. And I have no idea how to do that. Is there an API available that will help me with the PPP packets?
How hard would it be to write a device driver that simulates a serial port. The device can listen on a real serial port, interpret its contents to an extent, and then distribute the incoming data to multiple "virtual" serial ports, which the main application can then listen to for incoming traffic.
View 2 Replies
View Related
Aug 17, 2010
I'm trying to open ttySx from an interrupt.the kernel crashes. is it possible to open/write to serial port from interrupts ? I think it crushes because when I try to open the device there is a mutex lock which cause the kernel to crash , am I right
View 2 Replies
View Related
Aug 24, 2010
I had a web server running from a Windows 7 computer and recently moved everything to an Ubuntu server. All is set up and running smoothly. I do have one page that actually interfaces with the serial port. The only thing I do with it is to set the DTR pin to "true" which applies +12v to the pin. This activates a relay. It is very basic and simple. After moving everything to Linux, this page will no longer work. I knew this would happen. I know the page had code in it to call out "Com1" which would change to "ttyS0". It also had "set_serDTR(True);" in the code. I can't figure out how to get PHP to control the DTR pin on a Linux serial port.
View 10 Replies
View Related
Aug 16, 2010
I want to write data to serial port ( ttyS ) from inside the kernel.
View 5 Replies
View Related
Jul 29, 2009
I successfully installed the virtual box on my fedora 8 system, and also created a virtual machine with windows xp OS, it works nicely, I try to configure the serial port of my virtual machine and try to configure the path for the port "screen shot are attached" it gives me the error message also the "screen shot are attached" for your review.Is kind of mistake is going on during the path setting, and how to set the path for configuring the serial port of my virtual machine so that I can use the hyper terminal tool of windows.
View 4 Replies
View Related
Jun 1, 2010
I have been working on writing a small rs232 driver like minicom for months. I am almost there, I have the interrupt service routine running, I can read() ok. However when I write(), it returns the number of characters written, 1, but nothing is actually written out the port. I researched termios, and they say that serial port programming is really messy in linux/unix.
I am probably not setting up the port parameters correctly, or my write() function is not doing what it is supposed to. As I said, write() is returning successful. Other comm programs run ok (picocom & gtkterm) on my hardware. I am running knoppix/debian on an ancient computer. I saw other guys using slackware.
View 14 Replies
View Related
Nov 24, 2010
I have a serial port program which is reading a string .if(read(readfd,sResult,1)>0)where sResult is unsigned char sResult[10];if sResult is array of 10 then iam getting string perfectly but if iam making sResult only as unsigned char I am getting NULL value CODE BELOW
Code:
unsigned char sResult;
main()
{
readfd = open("/dev/ttyUSB0", O_RDONLY);
if (readfd == -1)
{
perror("READ: open_port: Unable to open /dev/ttyUSB0-
[Code]...
View 2 Replies
View Related
Jan 14, 2015
Basically I'm intending to write serial RX signal handler.Application receives defined packages of data over serial which contains header and payload. Handler should analyse incoming stream and upon detection of header (header is 6B in length) switches to receive payload of length defined in header, then after receiving full message packs it and sends to application for handling.Problem I'm facing is that at random moments in signal I receive errors that "Resource temporarily unavailable" while reading from ttyOx device and I see that sometimes I miss incoming data.Also is it possible that if while I'm handling signal one more signal arrives and it is started to be handled parallel? If it is, what are the ways to prevent it? So I would be sure that no more signals will fire on same peripheral until I will finish handling what I have on my hands now.
Serial open and init:
Code: Select allint open_port(int port_nr) {
int fd; /* File descriptor for the port */
switch (port_nr) {
case 1:
fd = open("/dev/ttyO1", O_RDWR | O_NOCTTY | O_NDELAY);
break;
[code]....
View 5 Replies
View Related
Aug 31, 2009
I have got a problem while reading from the serial port. I'm working on iMX-31 board and Eclipse IDE. Whenever I'm trying to read any data through the serial port, it's displaying I/O Possible and the application is being terminated. After reading I'm trying to write this data on a file. Here are the excerpts from the code:
# int main()
{
if (openport()<0)
[code]...
View 7 Replies
View Related
Jul 19, 2011
I'm working on program that is going through setting different baud rates onto a config file. After I set a new value i want to check if it's the correct one by reading from the serial port on the server unit. I know what to expect if it's the correct baud rate so that's no problem, but searching through the internett i've yet to find a compact solution to my problem.
View 1 Replies
View Related
Jun 10, 2009
I have been reading data(non-canonical input) off a serial port in a loop. The device I am connected to sends the data in a bursty manner and I have to read using the loop. The device sends some data when initially powered on which I am supposed to read. I can then send "commands" to the device over the serial port. The "command" is supposed to be "debug d 35 5 0"After I send the command there is some data that is sent back by the device to show that the command was successful. This command should elicit the right response from the device but it responds correctly some times while other times it does not. (when I try to write the consecutive commands) If I send two consecutive commands after reading the initial data and the command feedback I face some problems.
View 10 Replies
View Related
Jan 8, 2009
I bought a set of 3 laser sensors and it came with a software and its C++ source code for windows to receive the lasers info through the serial port. Since the entire project is running on Linux, I need to port the windows code to Linux. At the present moment, I already can receive the data from each of the 3 sensors, but the info is coming concatenated! Tracking down the original windows code, I found that it is probably happening cause I didn't ported these lines to my Linux version:
Code:
COMMTIMEOUTS CommTimeouts;
[...]
CommTimeouts.ReadIntervalTimeout = 2;
[code]....
I've searched already about how to specify the serial port timeouts on Linux, but didn't find a solution. how to port these lines to Linux or maybe where to find more info about how to set serial port timeouts on Linux?
View 4 Replies
View Related
Mar 8, 2011
I'm currently developping a C program to drive a Telit GM862-GPS module using the serial port of an embedded board (SBC9261).The communication with the module is based on AT commands : I just send my command to the module, through the RS232 line, and the module answers immediately.Here's an example with a basic command returning the GPS's acquired position, sent with Minicom :
Code:
AT$GPSACP
$GPSACP: 104323.000,4x45.6171N,00x38.6219E,0.8,446.5,3,272.14,0.21,0.11,080311,09
[code]...
View 4 Replies
View Related
Jan 29, 2010
Driven by my needs , i need to toggle only the flow control (RTS, CTS) bits and have nothing to do with the rest of the functionality (e.g. normaltx , rx operation). I am presuming that there exists a line discipline from user space for toggling RTS as ioctl (*file, cmd, *unsigned long ) can be used easily to toggle RTS. However, the use of IOCTL in kernel space for the same purpose brings about no change on RTS (oscilloscope shows no change). google led me to this [URL] and according to that i should make changes directly in the driver.
Code:
int x=0;
int actual_module()
{ int k;
mm_segment_t oldfs;
[code]....
View 3 Replies
View Related
Aug 2, 2010
how to configure serial port RS-232 to use flow control? The reason is without flow control is is not working properly(dala loss etc.) Im trying to run it as it is just with setting the flow control flag and Im sending my data via loop-back on the rs-232 to GTK TERM on the same computer... but when I enable IXON/IXOFF in GTK TERM, my sending program cant even open the port...
My current settings is:
Code:
struct termios termios_p;
//ferme_port();
tcgetattr(sc.fd, &termios_p);
termios_p.c_cflag = B9600;
[Code]....
View 2 Replies
View Related
Sep 22, 2009
I am writing a program to read and write to devices over my serial port. My program will need to connect to up to four other machines at once. I can connect to machines successfully, it works well. However, after I connect and disconnect once, attempting to connect again will cause the FIRST serial connection will fail and all the ones after it will pass.
e.g.
Code:
fd[0]=connect("/dev/ttyS0");
fd[1]=connect("/dev/ttyS1");
fd[2]=connect("/dev/ttyS2");
fd[3]=connect("/dev/ttyS3");
code....
That works as long as it is executed only once in the program. The second time it is executed, fd[0] will die and fd[1-3] will work normally.I can't figure out why this happens, but I found a workaround by connecting to "/dev/null" before any real serial ports.What should I do?
View 10 Replies
View Related
Apr 11, 2009
I have connected a device to my linux system with a serial cable (rs232). The settings are: port /dev/ttyS0, baud rate=38400, data bits=8, stop bits=1, no parity, no hardware or software handshaking. I wrote a linux program that sends 1 byte to the device, but the device doesn't receive it. I know the serial ports are working because when I use the CuteCOM application to send data, the device DOES receive it, so obviously it is a problem with my code..
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
[code].....
View 2 Replies
View Related
Aug 25, 2010
i want to try with a small application in linu in that i want to read some data from controller using serial port and i wanna transfor that data to another meachin in the network for this i want serial port interfacing programming as well as socket programming.
View 1 Replies
View Related
Apr 16, 2011
How do I install Javax.comm for serial port programming. I have been all over the Internet without finding anything useful. I did install the librxtx-java package, but still eclipse or monodevelop will not recognize import gnu.io. I am using eclipse. What am I doing wrong. Surely, it should not be this difficult. I might have to do this in C++, or Basic even (Gambas2) if I can not figure this out.
View 1 Replies
View Related
Aug 5, 2010
I want to send something through the serial port, for example
[code]...
the point here is send some numbers to a couple of 7 seg displays, so I will wire a RS232 chip on a protoboard, the logic after the RS232 is not an issue, but how can I assure the data is being sent right from my linux box to the RS232 chip, the one on the protoboard? Do I have to write a C program to read the strings and then send them to the serial port?For example if I wanted to send this to the displays:
[code]...
So I guess the simplest way is (Supposing I can deal with the stream so it is filtered and only display the number array) $ ifstat > /dev/ttyS0 But, how do I know if the RS232 will take them as the right characters?
View 3 Replies
View Related
Dec 27, 2010
I am doing work on serial port. I want to send/receive data to/from Microcontrolar through serial port. But I don't know how to initialize, receive and send data to Serial port. i am new in fedora so i hav'nt any deep concept of fedora.can anyone send me C code , which communicate through serial port in fedora (or atleast help me). I am using Fedora 11.
View 6 Replies
View Related