LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

setting serial config parameters

Hi,
 
I was wondering if someone can help me with serial configuration. Basically i am trying to send and receive data via serial RS232. I am using the RS232 utility available. When setting the config setting for comport, baudrate, parity bits and so on, in the serial user interface i already hv a configuratiion by default...say comport 1, baudrate 9600....and so on. But say the user changes the setting according to his needs....currently i have it set up as if he changes it and the runs the program....stops it and then runs again...it saves the last changes he made up until he quits the program.......and the next time he starts the program the setting have gone back to default position.
 
Is there any way i can save the changes he made to the setting so that the next time he loads the program, the new default values are there and not the orginal values.
 
Looking forward for a prompt response.
 
Thanks
 
k1_ke
0 Kudos
Message 1 of 6
(3,461 Views)
If I have correctly understood your situation:
1. You are using OpenCom function in RS232 library. This function relies on Control Panel settings for the com port
2. The user may want to change communication settings and he wants to maintain these settings
3. You would like these settings to update default port settings in Control Panel
 
I do not know were exactly those settings are stored (presumably in the Registry), but I usually not rely on windows settings for com port since the port could be used by my customer to communicate with other devices with different port settings than my equipment. For this reason, I use OpenComConfig function instead of OpenCom exactly to be able to set my own port settings.
In case your application needs to use different settings, you could save actual settings anywere (on a configuration file or in the registry for example) and reload them at new application start before opening the port.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(3,461 Views)

Hi Roberto,

Thanks for the prompt reply. Yeah you hv understood my problem correctly. Yeah i would like the new parameters to be loaded the next time the user starts the program rather than the default. i do use OpenComConfig(). below are the few bits of code. Currently i am able to keep the new values provided the user doesnt quit the program. so for e.g if i changed the setting...ran the program...stop it changed it again and then went back to see it, it had the last change i made....but the moment i quit n load again...it goes back to default parameters..

Hope you can help me out.

Thanks

k1_ke

below is the code...

int CVICALLBACK ConfigCallBack (int panel, int control, int event,void *callbackData, int eventData1, int eventData2)
{
    switch (event)
        {
        case EVENT_COMMIT:
            config_handle = LoadPanel (panel_handle, "serial.uir", CONFIG);
            InstallPopup (config_handle);
             if (config_flag)    /* Configuration done at least once.*/
                SetConfigParms ();
            else                /* 1st time.*/
                config_flag = 1;
            break;
        case EVENT_RIGHT_CLICK :
            break;
        }
    return(0);
}
int CVICALLBACK CloseConfigCallback (int panel, int control, int event,
                                     void *callbackData, int eventData1,
                                     int eventData2)
{
    switch (event)
        {
        case EVENT_COMMIT :
            port_open = 0;  /* initialize flag to 0 - unopened */
            GetConfigParms ();
            DisableBreakOnLibraryErrors ();
            RS232Error = OpenComConfig (comport, devicename, baudrate, parity,databits, stopbits, inputq, outputq);
            EnableBreakOnLibraryErrors ();
            if (RS232Error)
             DisplayRS232Error ();
            if (RS232Error == 0)
            {
                  do s
              }
           else
             EnablePanel(1);
             DiscardPanel (config_handle);
             break;
         }
     return(0);
}
 

Message Edited by k1_ke on 01-23-2006 12:15 PM

Message Edited by k1_ke on 01-23-2006 12:15 PM

0 Kudos
Message 3 of 6
(3,455 Views)

Hi Roberto,

I was reading over the help files and came across SavePanelState ()..i tried using it but doesnt seem to work for me.

SavePanelState (panel_handle, "serial.uir", 0);

Please let me know if i can use something else inorder to save the setting before quiting the program.

Awaiting reply.

Thanks

k1_ke

0 Kudos
Message 4 of 6
(3,436 Views)

Hi,

I would just like to inform you that i was able to figure my problem out. By using SavePanelState ()..and RecallPanelState() i was able to keep the new parameters after the changes...

Thanks for the help!

k1_ke

0 Kudos
Message 5 of 6
(3,432 Views)
I'm happy you find a solution to this problem. Just keep in mind that you are lkely to encounter an error if the structure of your panel changes beween saving and recalling its state: in this case you may need to filter out this error and start the application loading some default value instead of the previous recorded parameters.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 6
(3,424 Views)