Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Nov 18, 2017 11:51 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Jul 28, 2009 3:23 pm 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
Question

How can I change my TREQ-M4 serial port to EIA-232 or EIA-422 in the settings?

Answer

The attached .zip with this topic contains two programs that can be executed from a USB stick attached to a TREQ-M4 to switch between EIA-232 or EIA-422. If you would like to add this to another program here is example code:

Code:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
g_hPWDevice = CreateFile(TEXT("COM1:"), GENERIC_READ|GENERIC_WRITE, 0, NULL,
                    OPEN_EXISTING, 0, NULL);
       
        dwIn=UART_RS232 ;//GPIO_MP_RS232;
        //        dwIn=UART_RS422; //GPIO_MP_RS422;
        int ret=DeviceIoControl(g_hPWDevice, IOCTL_SERIAL_SET_MPORT_CONFIG,
                                                &dwIn, sizeof(dwIn),                                // in buffer & size
                                                NULL,NULL,              // out buffer & size
                                                NULL,NULL);
        if (!ret)
        {
                printf("IOCTL_SERIAL_SET_MPORT_CONFIG failed 0x%X\r\n",GetLastError());

        }
        ret=DeviceIoControl(g_hPWDevice, IOCTL_SERIAL_GET_MPORT_CONFIG,
                                                NULL,NULL,                                        // in buffer & size
                                                &dwOut, sizeof(dwOut),             // out buffer & size
                                                &dwActualOut,NULL);
        if (!ret)
        {
                //failed
                printf("IOCTL_SERIAL_GET_MPORT_CONFIG failed,error code 0x%X\r\n",GetLastError());

        }else{
                printf("IOCTL_SERIAL_GET_MPORT_CONFIG dwActualOut 0x%X, dwOut 0x%X\r\n",
                                dwActualOut,dwOut);
                }

if(!CloseHandle(g_hPWDevice))
        {
                return 0;       
        };
       

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
For your reference:

The dwIn= 0 ( or GPIO_MP_RS232 depends on for M4 or TREQ-L2 .

" M4's TREQPUBLIC.h:
typedef enum
{
    UART_RS232 = 0,
    UART_RS422 = 1,
    UART_RS485 = 2,
    UART_RS_UNKOWN=0xff
}UartType;
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"TREQ-L2's TREQPUBLIC.h
//////////////////////////////////////////////////////////////////////////////////
// For multi port setting on TREQ-L2
enum {
        GPIO_MP_RS232        =        0x00000040,                //GPIO_MP_MPEN0,        GPIO_MP_n232EN0 is set low to enable rs232
        GPIO_MP_RS422        =        0x00000250,                //GPIO_MP_T422EN0|GPIO_MP_MPEN0|GPIO_MP_n232EN0
};

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Attachments:
TreqM4_232_422.zip [4.41 KiB]
Downloaded 304 times

_________________
Ron L.

http://www.beijerelectronicsinc.com/
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group