Programming :: Switch Between Serial Protocols?

Jun 7, 2011

How to switch between serial protocols in c language? for example i need to switch between rs232 and rs422,(according to rs422 pinout)

View 2 Replies


ADVERTISEMENT

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

Hardware :: Check The Status Of A Switch Though Serial Port?

Oct 20, 2010

I would need to monitor the status of an electric relay. To do so I was thinking the serial port and perl (as I don't know C ) how to check if a switch connected to a serial port is open or closed. Here is my plan, I'll plug a electric relay on the electric network and monitor the state of the switch. if the switch is closed, that mean that we are on the electric network if the switch is open that mean that we are on our diesel power generator.

PS: There will be no voltage input involve (although I can if that's required)

I'm planning to use this with Nagios to know if we are on the electric network or on our diesel power generator.

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

Programming :: Get Serial EAGAIN Error

Apr 5, 2010

I use serial port. I get serial EAGAIN error. I open serial port with below settings.

do I have any error with settings.

static int fd=-1;
bool openPort(int baudrate, const char * ThePort) {
unsigned long BAUD;
struct termios port_settings;

[Code].....

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

Programming :: Python Serial And Struct On 64 Bit?

May 14, 2010

For a work project, I've got a bunch of python code from about a year ago that controls the movement of our EVI-D30 camera over a ttyUSB connection. It used to work fine on a 32-bit Fedora box, but recently we moved our whole project over to a 64-bit Gentoo server, and the same code seems to be worthless on the new platform. I didn't write the code, so I'm have trouble figuring out how to fix it. Error messages usually look like this:

Code:

File "./CameraController.py", line 172, in pan
turn_callback(cmdStruct[0], cmdStruct[1])
File "./CameraController.py", line 147, in turn_callback
cameras[camera].TiltUp()

[code]....

View 13 Replies View Related

Debian Programming :: Serial Input In Scripts

Jun 10, 2013

I need a way to use serial input such as through an Arduino in Debian scripts, in any usable language.

View 2 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 :: 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

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

CentOS 5 Hardware :: NetMOS PCI 9835 Dual Serial Card - Can't Use The Serial Ports

Feb 21, 2009

On my CentOS 5.2 install I've installed a dual-port serial card based on the NetMOS 9835 chipset. I've followed the serial instructions, but everything they tell me to do is already done - see setserial outputs below. I've compared these values to the lspci output (below, NetMos card is at the bottom of the output) for the card and it appears right. Problem being, I can't use the serial ports. Oh and I did use search, and looked at every 9835-related article before posting this :)

[Code]....

View 17 Replies View Related

Debian Hardware :: How To Get Old Serial-touchscreen To Work With USB / Serial Adapter

Oct 9, 2015

I am hoping to be able to get an old serial-touchscreen to work with a usb/serial adapter. I had this touchscreen working some years ago on different hardware. I would like to hook it to the machine I am setting up as a multimedia host with mythtv among other things.

Following the instructions I left behind when I got this to work way back when does not work. See [URL] ....

This info is a work around to get the xserver to see the touchscreen. [URL] ....

I do know that the touchscreen works as I am able to get garbage on the screen as in the first part of my howto. But I have not had any success getting xorg to see it. I wish I had posted a copy of the xorg.conf at the time, but......

There is an issue with the current xserver in testing that I am hoping the next update (in unstable) will fix when it gets pushed to testing. That is that Code: Select all# X -configure fails with a segfault. So I am not able to generate the xorg.conf needed to get it to work. I was going to post a bugreport, that is when I found out there is an update in unstable, so I am waiting for it to get pushed at the moment.

Anyway I am hoping that I can link /dev/ttyUSB0 to /dev/tty0 and get it to work. I would like some kind of guess as to my chances of success before I go to all the work of getting the monitor hooked to the host.

View 1 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 :: Get Hard Disk Serial Number On Solaris?

May 23, 2011

I want to get the Hard Disk serial number of SCSI HDD on Solaris. On linux this is done using following structs and API:

struct hd_driveid hd;
int ide;
ide=open("/dev/hda",O_RDONLY);
(void)ioctl(ide,HDIO_GET_IDENTITY,&hd);
(void)printf("Serial number - %s
",hd.serial_no);

Is there any similar method exists in Solaris to get HDD serial number.

View 1 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 :: 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 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







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