C Programming Change Serial Channel Mode from RS-232 to RS422 - c

I am working on a software for testing serial channels on my setup running on Linux OS. To configure channel settings such as BAUD rate, parity, etc., I used functions in <termios.h>. However, I do not know how to change channel mode from RS-232 to RS-422 mode.
I tried to use functions in <termios.h> and some ioctl commmands.

Related

What are the possible ways of setting custom baud rates for serial ports in Linux user mode and kernel mode?

What are the possible ways of setting custom baud rates for serial ports in Linux user mode and kernel mode?
I see TCGETS2/TCSETS2 ioctl calls to achieve this. Is it possible to set custom baud rates without any special ioctls?

How to read USB serial input in a cross-platform way in C?

I'm trying to read serial input from a USB device with 9600 baud into a C program, but I'm not sure how to go about this. The program input will be really simple. I have a circuit set up with a potentiometer and its sending the voltage value every second over the USB.
How do I read this into a C program being developed on Windows? I'd prefer something cross-platform if possible.
I assume you are using arduino-like device, which can be easily configured to output serial data over USB. See a tutorial on the subject.
USB is not as simple as legacy serial ports and USB devices will need drivers. Class compliant devices are usually supported directly by operating system, see USB device classes, at least to some extent.
For example, if you are using Arduino, the simple way is to install FTDI drivers (see their website) and use the virtual COM port provided by the driver.
Communication over a COM port is a well-covered subject and you should be able to find a vast number of documentation over that. There are also cross-platform serial communication libraries that could make your development easier.
Then you could also write your own library for the device, but that would probably be an overkill if all you want is to read in a voltage.
You can either do something like this in your code to write seperate functions for Linux and windows...
#ifdef __unix__
...
#elif defined(_WIN32) || defined(WIN32)
#define OS_Windows
#endif
Or search for C libraries for cross-platform serial communication, here is one I found for C++ in one google search https://github.com/wjwwood/serial.

How to dump/burn program into LPC2148

I have LPC2148 daughter board but I am not able to dump/burn code into it, and it doesn't have any usb connector to dump code.
I read on internet by using FT232RL I can able dump code into LPC2148 but I am not able to do so.
please give me solution
thank you..!
The chip supports In-System Programming (ISP) via an on-chip boot loader ROM.
From the User Manual UM10139:
Programming of the Flash memory may be accomplished in several ways:
over the serial built-in JTAG interface, using In System Programming
(ISP) and UART0, or by means of In Application Programming (IAP)
capabilities.
The function of the FT232RL you mentioned is to act as a USB/UART bridge and is necessary primarily because modern PCs lack legacy RS-232 serial ports. You can in fact purchase a USB-Serial cable or adapter which will contain a bridge chip such as the FT232RL. Most of these use RS-232 line level signals, so you would still need an RS-232 line driver/receiver to connect then to your board (if your board has a serial port, it probably already has a line transceiver and you can connect directly to that). It is possible from specialist suppliers including FTDI themselves to get a USB cable with integrated FT232 and bare TTL level connections to connect directly to LPC2148 UART0 Rx/Tx lines.
If your board does not already expose a UART0 serial port and the necessart control to start the boot loader, a Serial Port Bootloader Interface board is available. For that you may then also need a USB/Serial adapter or a PC with a legacy serial ports.
Once you have a suitable serial connection, you will need the LPC2000 Flash Utility software to run on the PC.
The JTAG option is however faster, and more powerful since the JTAG is both a programming and debugging port. With a suitable toolchain and JTAG adapter it is possible to program and execute code with source-level PC hosted debugging including break pointing, data watching and single stepping of the code.

Interface Serial Modem to ttyS0 in AM1808 Embedded Linux

I need to implement the Serial Modem interfacing with the ttyS0 port of the AM1808.
In AM1808 all these three serial ports are interfaced in following manner.This has been predefined in the driver of TI (8250.c)
ttyS0 : Normal Mode
ttyS1 : loopback Mode
ttyS2 : loopback Mode
Now i want to use ttyS0 serial port for GSM modem. For that I need to configure ttyS0 in full mode.
My pins requirements are as following and i have interfaced the pins as following.
UART0_TX
UART0_RX
UART0_RTS
UART0_CTS
UART0_DCD (this pins are right now on GPIO)
UART0_DTR (this pins are right now on GPIO)
What i should do wether i need to change the driver of TI for the same ?
How i can do it ?
Guide me.

Activate and deactivate usb device in c?

We have a laser scanner which is connected all the time to a certain usb port.
The usb device should be deactivated normally.
Only at certain times I have to activate this usb device at the usb port with a litte c program.
So how can I activate a deactivated usb device in c?
Thanks for your information.
Update:
I forgot to mention to operating system: Windows XP, Windows Vista, Windows 7, ...
The laser scanner is a Honeywell Voyager MS 9540 product.
In the documentation I read that if the usb scanner is connected to a serial port, you can send enable and disable commands over the serial port in order to enable or disable scanning. But I thought it would be easier to simply enable or disable a usb port/device.
I bit more information would be useful ...
For usb connection you can use libusb (see also: libusb-win32). Since it's used by CUPS (a printing software) too, i guess its ideal for you.

Resources