Programming :: Porting Serial Port Program From Windows?

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


ADVERTISEMENT

Programming :: Serial Port Program Not Outputting The Right Data?

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

Programming :: Serial Port Communication Program Always Lose One Byte Data: 0x00?

Dec 13, 2009

I wrote a serial port communication program to access a equipment.

int main(void)
{
int fd = 0;
int nread = 0,i = 0,nwrite = 0, tmpread = 0, m = 0, n = 0 ;

[code]....

View 2 Replies View Related

General :: Windows With Putty Via USB Serial Cable To Serial Port - Output Ok, Input Isn't?

Jan 13, 2010

I am trying to get two way serial communications going between a Windows XP system and a Linux system (RHEL 5).I have /sbin/agetty -L 9600 ttyS0

in /etc/inittab. I am using a generic USB to serial adaptor on Windows (Unitek) and a null modem cable. I have putty configured for 9600 baud, 8 bits, no parity, one stop bit, no flow control.I get the login prompt from agetty in the putty window but input does not work; I see weird characters in the putty screen. I can echo output into the device from windows and see it, but

cat < /dev/ttyS0. just prints out weird characters from what I type.

View 3 Replies View Related

Software :: Identify The Status Of Serial Port ("Port Already Opened") From A C Program?

Feb 5, 2010

I am writing some application in C, which will access a serial port device (RS232). My application is working good. But if any other application is already opened the port, I couldn't able to identify that. In windows VB program, while accessing comport through mscomm control, i am receiving an error as "Port Already Opened". But in Linux environment, through C program how can i get that? I am accessing comport 1 as follows

fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_SYNC);

View 3 Replies View Related

Programming :: Finding A Documentation To Port A Windows Program?

Jun 23, 2010

I'm using ubuntu 9.04; I have a large project in windows that I want to "port" it in linux.
It uses IPC mechanism "Shared memory" and also "Critical Section" APIs in windows, but unfortunately I have no good reference to change these windows APIs to their equivalent in linux?

Is there a comprehensive documentation or reference for this issues? I mean a table containing the equivalent APIs or systemcalls in windows and linux! For example, what's an alternative for the "InitializeCriticalSection" API in linux? Or an alternative for "CRITICAL_SECTION" structure? Or even an alternative for "RegOpenKeyEx", although we don't have registry in linux!!

View 1 Replies View Related

Programming :: Ubuntu 9.04 - Porting Function On Windows?

Jun 23, 2010

I use ubuntu 9.04;I have a function called "isLogEnabled" in my project on windows, I wanna port it to linux. I know that I should have a "config.h" file in linux to get log from a specific Shared object and ..., but because I'm new to linux, I don't know how this should be done.

This is my function:
Code:
//This function return True if log policy is set in registry and False otherwise
int isLogEnabled()
[code]...

View 14 Replies View Related

General :: Serial Port Programming Help

Apr 15, 2010

can we use inb() and outb() functions for serial port programming ??

View 5 Replies View Related

Programming :: C - Serial Port Won't Open?

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

Ubuntu :: Serial Port Emulation In Windows

Apr 5, 2011

I am trying to use one serial port simultaniously for two different programs. I have a two programs that use GPS information that I would like to run at the same time. At this time only one program at a time can access a serial port. I have found a way to emulate this in Windows so that I can have both running, now I'm trying to do the same in Ubuntu. Is it possible? If yes, How? The GPS receiver is connected via a USB port.

View 1 Replies View Related

Programming :: Read X Bytes From Serial Port?

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

Programming :: Intercept Data On Serial Port?

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

Programming :: Serial Port Communications - CPU Bandwidth

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

Programming :: Send Data Through Serial Port Using C?

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

Programming :: Multiple Protocols On Serial Port

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

Programming :: Opening A Serial Port From Interrupt?

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

Programming :: PHP Serial Port No Longer Work

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

Programming :: Writing To Serial Port From Kernel?

Aug 16, 2010

I want to write data to serial port ( ttyS ) from inside the kernel.

View 5 Replies View Related

Programming :: Rs232 Serial Port Programming?

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

Programming :: Serial Port Programming String?

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

Debian Programming :: Serial Port Signal Handler

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

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 View Related

Programming :: Displaying I/O Possible When Reading Data From The Serial Port?

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

Programming :: Getting Information From Serial Port On Server Unit

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

Programming :: Inconsistency In Transferring Commands Over Serial Port?

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

Programming :: Read Datas After Write On Serial Port?

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

Programming :: RTS Toggling In Serial Port From Kernel Space?

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

Programming :: Configure Serial Port RS-232 To Use Flow Control?

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

Programming :: Serial Port Becomes Unreachable After Being Opened And Closed Once?

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

Programming :: Read Some Data From Controller Using Serial Port?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved