How to keep alive RS232 connection

Hello everyone. I have a problem with RS232 communication. To activate the connection I have to send the string "RS232", then to keep it alive I have to send every second CR, but in the meantime, I must be able to send other character strings without delay on the same port (COM7). Can anyone help me?
Thanks 
Solved!
Go to Solution.

RS232 standard does not require by itself to be kept alive someway, so I suppose is your remote device that requires it.
In every case, you could create a 1-sec timer and have its callback send CR periodically over the serial port.
To avoid conflicts between this task and the rest of the application you could use a lock: basically, after creating the lock, each function that wants to access the serial port must call CmtGetLock (), operate on the port and call CmtReleaseLock () afterwards. If the lock is owned by another function, other functions trying to get access are frozen waiting for the lock, so you must be careful in designing com-related function so that they are fast. If you do not want to have some function be blocked while waiting for the lock you can use CmtTryToGetLock instead of CmtGetLock. A few informations on locks can be found in this tutorial as well as in this chapter of the Programmer reference.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?

Similar Messages

  • How to Keep Alive a specific HFM application

    My PRD landscape has 2-3 applications. Whenever any application loads for the first time in the memory, it takes quite some time before it is loaded. Once the application is loaded, the response times are pretty quick and acceptable.
    During specific parts of the day / month, a specific application becomes active. During this time, other applications may or may not be used, but one specific application is definitely used. I want to keep this application's cubes loaded in the RAM, so that response times are quick, whenever the user needs it - whether for the first time or otherwise.
    How to keep alive a specific application's cubes alive and loaded in RAM? I am not looking for general solution like setting the "FM Service" to Automatic (currently it is set Manual) - setting this to Automatic, will affect all applications. However, I am looking for a specific application at a specific period of time.
    I am ok with a custom solution if required. Let me know, what are my options.

    I think you are looking for an inappropriate solution to your problem. Most HFM applications take a few seconds to start up. If your application takes such a long time to start up you really need to examine the root cause. Start by removing the Sub NoInput and Sub Input routines in your rules to see if this is the reason the application takes so long to start.
    If the removal of those routines does not significantly change the startup time, look through the event logs for possible causes. It is possible you have a connection problem with the Oracle database for example, or you have an environment configuration problem where the HFM application servers have a very slow connection to the database server, or possibly the database server performs poorly.
    I strongly suggest you investigate these root casues first before trying to make HFM behave in a non-standard way. Certainly you can start the HFM Management Service, which will start all of your HFM applications and keep them all up and running. This approach does not allow the applications to shut down on their own though. Only use this if you have exchausted your investigations (as I suggsted above).
    --Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Workstation keep-alive and connectivity failure detection

    Dear all,
    I intend to automatically detect network failures from my workstation client and have it attempt to reconnect to the server on its own.
    Browsing the documentation for related information I saw the keep-alive option. If I understood correctly you can have the workstation generate periodic keep-alive messages to the server and if these are not acknowledged, all subsequent ATMI calls will fail with TPESYSTEM.
    My doubts regarding this are the following:
    1) Is there some dummy ATMI function I can invoke periodically to check for a disconnection? Otherwise network failures might go by unnoticed if there are periods where my WSC doesn't require to communicate with the server.
    2) Once I get a TPESYSTEM failure, is there some way to programatically discriminate if the cause is a network disconnection? It is a pretty generic error after all.
    3) Once all ATMI functions start failing due to keep-alive detecting a network failure, can the system recover on its own? or must I reconnect to the server? What I mean is, maybe some keep alive messages where lost, the system passes to the 'disconnected' state, but then the K.A. messages keep being generated and upon correct acknowledgement of these, subsequent ATMI calls will stop failing.
    4) Does the WSC go to 'disconnected' state after the first unanswered keep alive message? or is there some sort of tolerance like, say, 'If N messages in a row are not answered then assume the connection to be dead'.
    I'm sorry if it was too long a post, but neither searching the documentation nor this forum clarified any of these issues for me.
    Many thanks for your attention.
    Regards.

    Cacho,
    1. I assume that you're talking about the WSL CLOPT option "-K
    {client|handler|both|none}", which causes periodic keepalive messages to be
    sent. When this option is used, there is no need for the WSC to perform any
    periodic operations to keep the network connection alive.
    However, if you are worried that the network might suffer a transient
    failure and you want to perform your first ATMI call after an extended
    period of inactivity as quickly as possible without waiting for another
    tpinit(), you may want to perform periodic dummy operations so that you can
    reissue the tpinit() if needed as soon as the network connection is
    restored.
    One option is to make a tpcall() to the ".TMIB" service with an FML32 buffer
    where TA_OPERATION is set to "GET" and the other fields are set to retrieve
    some system attribute. There is an example of how to call .TMIB at the end
    of the TM_MIB(5) manual page. You would want to perform a GET operation
    rather than the SET operation shown in that example.
    Another option is to write a null service in one of your application servers
    which just calls tpreturn() and have your client make periodic cals to that
    service.
    Calling a verb such as tpalloc() or tpconvert() would not be sufficient,
    since these calls do not result in any network traffic.
    2. The tperrordetail() function is available in newer releases of Tuxedo to
    provide additional information about certain Tuxedo errors. When a
    workstation client is disconnected, tperrordetail(0) will return TPED_TERM.
    3. If there is a network failure, workstation clients must call tpinit() to
    reauthenticate to the system. This is necessary for security reasons.
    4. The keepalive option is passed down to the underlying network provider
    and Tuxedo has no further involvement with keepalive once it informs the
    network of this option. For Sockets the option passed is SO_KEEPALIVE; you
    can do a web search on SO_KEEPALIVE to see exactly how the network treats
    keepalive messages on your particular platform.
    Ed
    <Cacho Nakamura> wrote in message news:[email protected]...
    Dear all,
    I intend to automatically detect network failures from my workstation client
    and have it attempt to reconnect to the server on its own.
    Browsing the documentation for related information I saw the keep-alive
    option. If I understood correctly you can have the workstation generate
    periodic keep-alive messages to the server and if these are not
    acknowledged, all subsequent ATMI calls will fail with TPESYSTEM.
    My doubts regarding this are the following:
    1) Is there some dummy ATMI function I can invoke periodically to check for
    a disconnection? Otherwise network failures might go by unnoticed if there
    are periods where my WSC doesn't require to communicate with the server.
    2) Once I get a TPESYSTEM failure, is there some way to programatically
    discriminate if the cause is a network disconnection? It is a pretty generic
    error after all.
    3) Once all ATMI functions start failing due to keep-alive detecting a
    network failure, can the system recover on its own? or must I reconnect to
    the server? What I mean is, maybe some keep alive messages where lost, the
    system passes to the 'disconnected' state, but then the K.A. messages keep
    being generated and upon correct acknowledgement of these, subsequent ATMI
    calls will stop failing.
    4) Does the WSC go to 'disconnected' state after the first unanswered keep
    alive message? or is there some sort of tolerance like, say, 'If N messages
    in a row are not answered then assume the connection to be dead'.
    I'm sorry if it was too long a post, but neither searching the documentation
    nor this forum clarified any of these issues for me.
    Many thanks for your attention.
    Regards.

  • Keep Alive SMTP connection

    Hi,
    Is there any way to keep alive a SMTP connection forever using JavaMail? I know being a TCP connection, the connection will be broken if no data is exchanged for specific time. What if NOOP command is send to SMTP server as a heart beat. Can anybody suggest how this can be accomplished using JavaMail?
    Thanks,
    Atul

    You can call the isConnected method, but your server isn't going to like you if you
    keep a connection open even though you're not using it.

  • How to keep alive a session in Web Services?

    I have to do my project, that will be including some following features:
    1. Login to Application through Web Services method. For example:
    http://mydomain.com/web-services/Login?WSDL
    2. After logging in, use mySms method to send message to Cellphone through Web Services! For example:
    http://mydomain.com/web-services/mySms?WSDL
    My questions are:
    1. How can I keep alive the session after logging in the application in Web Services? In Web, I can use "Session".
    2. If someone has not logged in the Application, he/she could not use mySms method for sending Sms. How can I do that?
    3. I know, when I invoke a Web Services, one JavaBean has been called, and this bean is persistence with his own states. It means, if I set value to parameters of this bean, these values are persistence for invoked methods by other persons.
    For example:
    mySms bean has a private field "jid" inited with NULL value.
    Person A invoked mySms.
    Then, A set jid of mySms to value "A".
    Person B invoked mySms. B got jid value. He receive the result value is "A".
    The question is, how can I set mySms bean so that mySms bean is not persistence?
    Thanks many!

    Hi,
    I can right away answer your FIRST Question.
    Since WebServices are PURELY Based on SOAP which is in tern based on HTTP, they rely on a Stateless protocol.
    I am sure you know that the HTTP is the STATELESS Protocol and so you can not maintain Session and so EACH Http REQUEST is considered as a SEPERATE REQUEST.
    Now, still you want to maintain the Session in WebServices,
    The simple answer is PASSING PARAMETERS.
    Just Maintain your Session on Client (If you are using JSPs or Servlets to CAll WEBSERVICES then maintain Session through your HTTPSession) and each time you Invoke WebService PASS ON REQUIRED Parameters.
    This Approach is Exactly like your URL REWriting OR your Parameters Passing through QUERY STRINGS.
    I hope you got what I am saying!
    Take care,
    Himanshu/

  • Keep alive or Connect on Demand??!!

    My new router keeps on reconnecting/disconnecting byitself for some reason.... I wnt it to be on 24/7... My option is Connect on Demand atm, because I do not know what to keep near Keep alive option.. since there are seconds near it. PLZ HLP!!

    Well it is difficult to tell without knowing which router you have.
    Generally you find help in the manual which came on the CD with the router and is available online and in the help of the router web interface on the right. There you'll find something like this probably.

  • How to keep the internet connection alive?

    Hi, I am a new Macbook user and everytime my computer goes to screen saver or sleep mode it keeps losing the internet connection. Is this normal? Is anyway to keep the internet alive even is the computer goes to "sleep mode"?
    I mean, it is quite a pain to keep signing in at messenger everytime I wake up my computer or come back from screen saver
    Thank you

    I do not know of a way. When your computer goes into sleep mode, it basically shuts itself down and stores everything in memory. Nothing is moving or working because the whole point of sleep mode is to conserve the battery. If it is really bothering you, go into System Preferences and change the amount of time it takes for the computer to go to sleep.

  • OSB using socket Transport ,how to keep a TCP connection open

    hi my firends,
    i met a problem , our project need build an OSB to control a socket service which is able to transfer a big data file (maybe a voice file,*.wav),and the client program will play the voice file on live.
    So my solution is that : keep a socket (tcp) connection open,client listen port and makes date play.
    but i can't make the OSB socket transport alway open,it will timeout after a few second if have none date received.
    how could i deal with it ... pls let me konw if you have any idea...i will wait you on line
    thanks guys

    Hi,
    I'm not sure if that's achievable using OSB, and even if it was, I don't think OSB was designed having this type of application in mind...
    I understand that you need a media streaming solution and I'm pretty sure that there are plenty of tools out there that can help you in doing that, and maybe some of them can be integrated with OSB in some way...
    Cheers,
    Vlad

  • How to keep from losing connection to firefox and reentering user name and password when I close a message in my e-mail that I have read

    I use firefox for e-mail and am unsure how to close a message without losing the connection to firefox. Then I need to go through the tedious task of entering my username and password everytime I am finished reading the message and close it. How can I close the message without losing connection to firefox? Also, when I select "save my password" at the sign in page it never saves the information. Why not?

    You're welcome.
    You could always get a Gmail account(free), set that up as IMAP or Exchange, then forward all of the mail from your POP account to your Gmail account.

  • How to keep Canon 5dMk2 "connected" while shooting tethered

    Folks,
    Is there a trick?
    When I shoot tetherered LR3 loses contact with my camera (5Dmk2, but also 30D) way too quickly before shooting an image. Just fiddling with the props, set, lights, etc., is enough to lose contact. I have been turning the camera off and then back on but that's ridiculous.  I want just leave that rig set to make me a full screen image upon testing (firing shutter) and holding that image as long as I need foe extended checking. When I set it for live view on the tethered laptop I want it to stay open, as I probably have the laptop plugged in.
    What am I missing here in the way of a setting?
    jonathan7007

    First, a caveat...  I don't use tethered shooting much.  Infact, it's been at least a year, but my last experience...
    You generally lose connection when the camera auto-shuts off.  So if you set the camera to not do that (external power? Menu setting?) then you shouldn't lose connection.  But I don't remember if it's possible for that camera to be set to not auto shut off.. if not, set it for as long as you can.  At least, that's what I remember!  Sorry if I'm not more helpful!
    Cheers!

  • How to keep alive a session with a timeout

    my session have a timeout of 20 minutes (it's a system setting i cannot change)
    i run a program that generates a file excel that need 60 minutes to  end.
    i cannot run the program in background because OLE and creating excel is not supported
    is there a way to avoid my session time out?
    is there a way to make the sistem don't close my session while it's creating my file excel?
    thanks,
    Giacomo

    Giacomo,
    Try it.
    REPORT  zz_keep_alive.
    CLASS lcl_trigger DEFINITION.
      PUBLIC SECTION.
        METHODS: fim_timer FOR EVENT finished OF cl_gui_timer.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    CLASS lcl_trigger IMPLEMENTATION.
      METHOD fim_timer.
        cl_gui_cfw=>set_new_ok_code( new_code = 'ONLI' ). "ONLI = Executar
      ENDMETHOD.                    "fim_timer
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    DATA: r_timer   TYPE REF TO cl_gui_timer.
    DATA: r_trigger TYPE REF TO lcl_trigger.
    PARAMETERS: p_uzeit TYPE sy-uzeit.
    AT SELECTION-SCREEN OUTPUT.
      p_uzeit = sy-uzeit.
      CREATE OBJECT: r_timer, r_trigger.
      SET HANDLER r_trigger->fim_timer FOR r_timer.
      r_timer->interval = 60.
      r_timer->run( ).
    Hope it helps.
    Rgs
    Paulo Afonso Cordeiro

  • How to keep the connection alive?

    Hello! Happy new year!
    I have to write an HTTP server that comunicates with many clients in the same time,but keeps the connection with a client open if there the corresponding header is Keep-Alive. I have used threads,and I've tested my program in the following way: I've requested the one page of the site and then I've followed a link from that page. I expected that the broowser and the server talk to the same thread every time,but it seems that they don't. The code I've written is:
    //HTTPServer class
    ServerSocket serverSocket = null;
            boolean listening = true;
            try {
                serverSocket = new ServerSocket(80);
            } catch (IOException e) {
                System.err.println("Could not listen on port: 80.");
                System.exit(-1);
            while (listening)
                  new HTTPMultiServerThread(serverSocket.accept()).start();
    //HTTPMultiServerThread
    public void run() {
         //     System.out.println(socket.toString());
              try {
    while(!serverSocket.isClosed())){
                  DataOutputStream out = new DataOutputStream(socket.getOutputStream());
                  DataInputStream in = new DataInputStream( socket.getInputStream());
                  int nrBytes = in.available();
                  if(nrBytes > 0){
                       byte[] bytes = new byte[nrBytes];
                       in.read(bytes);
                       System.out.println("Procesez mesajul:" + nrBytes + new String(bytes));
                       HTTPMessage processedMess = new HTTPMessage(bytes).processMessage();
                       System.out.println("Inchid conexiunea.");
                        log("log.txt", new HTTPMessage(bytes).getStatusLine() + " " + new Data().getCurrentTime());
                   //send the message   
    out.write(processedMess.getBytes(),0,processedMess.getBytes().length);
                       /* inchid conexiunea
                  else{
                       String ret = new String("HTTP/1.1 500 Internal Server Error\n");
                        ret += "Host: cristi\n";
                      ret += "Date: " + new Data().getCurrentTime()+"\r\n";
                      ret += "\r\n";
                      ret += "<html><body><p>HTTP/1.1  500 Internal Serve Error</p> </body><html>\r\n";
                      out.write(ret.getBytes());
                  out.close();
                  in.close();
                       if(new HTTPMessage(bytes).getHeaderValue("Connection").equals("Close"))
                  socket.close();
         }//end while
              } catch (IOException e) {
                  e.printStackTrace();
        }I would also like to know how many clients are waiting to be served,in order to develop statistics about the server response time. 10X

    hi
    same to u .
    i think what i get from ur code that ....
    use some vector at the server side and whenever any client is connected (offcourse first time or not (depend on u !!)) create an object corresponding(generally created by server for every client) ..
    save this in the vector .. and pass it the size of vector to the client with the response .
    may this help u .
    regards
    akash
    Indiagames Ltd
    [email protected]
    India

  • How do I change the http connection type from close to keep-alive

    I am using a browser that appears as though it needs a connection type of keep-alive. When a page is requested the server sends back a connection type of close. It appears images are not requested from the server when this connection type is requested.

    Some older web server provides inaccurate content-length information.If the content length value is less than the amount of data,the web server treats the difference as a new request, this creates problem with iplanet Web Server.
    If you are using browser with HTTP1.1 enabled, choose the option to enable it manually and try once again by posting the request.
    Hope it helps.

  • Weblogic proxy plugin closes keep-alive connections to clients randomly

    In short we have following arhitecture:
    clients ---> wl proxy plugin 1 ----> weblogic 1
    clients ---> wl proxy plugin 2 ----> weblogic 2
    Beacuse of the application/installation specific requirements, we are not using failover, one wl proxy always forwards requests to one weblogic (simple configuration).
    Application is TR-069 protocol based (SOAP over HTTP) so it very much relays on persistence TCP connections (Connection: keep-alive). This TCP persistence has to work correctly in order that TR-069 messages are exchanged in required order, otherwise we have a error on application layer.
    Here and there we've noticed applications errors which suggest that we have some problems in TCP connection between the client and the weblogic server. After sniffing, we've noticed that weblogic proxy plugin (Apache) randomly, or because of some other reason we do not know, decides to close TCP connection to client, even app on weblogic did not request so ???
    As a result, client opens new connection to the server with new TR-069 session and it gets bounced beacuse it allready has one open on weblogic server.
    We've sniffed, traced everything we could, we were searching for patterns in time, etc... but we can not find the reason why proxy plugin decides to close the connection to the client (not to the weblogic server).
    Trace (replaced sensitive information):
    Thu Apr 29 15:05:50 2010 <958012725463463784> URL::parseHeaders: CompleteStatusLine set to [HTTP/1.1 200 OK]
    Thu Apr 29 15:05:50 2010 <958012725463463784> URL::parseHeaders: StatusLine set to [200 OK]
    Thu Apr 29 15:05:50 2010 <958012725463463784> parsed all headers OK
    Thu Apr 29 15:05:50 2010 <958012725463463784> sendResponse() : r->status = '200'
    Thu Apr 29 15:05:50 2010 <958012725463463784> canRecycle: conn=1 status=200 isKA=1 clen=545 isCTE=0
    Thu Apr 29 15:05:50 2010 <958012725463463784> closeConn: pooling for '$IP$/$PORT$'
    Thu Apr 29 15:05:50 2010 <958012725463463784> request [$URL$] processed successfully..................
    !!!! Now it closes the TCP connection and inserts "Connection: close" HTTP header !!!
    WL proxy plugin conf params are:
    WebLogicCluster $IP$:$PORT$
    DynamicServerList OFF
    KeepAliveTimeout 90
    MaxKeepAliveRequests 0
    KeepAliveSecs 55
    Apache worker configuration is:
    <IfModule mpm_worker_module>
    PidFile var/run/httpd-worker.pid
    LockFile var/run/accept-worker.lock
    StartServers 2
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadLimit 200
    ThreadsPerChild 200
    MaxClients 2000
    MaxRequestsPerChild 0
    AcceptMutex pthread
    </IfModule>
    Why weblogic proxy plugin ignores Keep-alive directive and decides to close connection to the client by itself?
    Any help?

    If a WebLogic Server instance listed in either the WebLogicCluster parameter or a dynamic cluster list returned from WebLogic Server fails, the failed server is marked as "bad" and the plug-in attempts to connect to the next server in the list.
    MaxSkipTime sets the amount of time after which the plug-in will retry the server marked as "bad." The plug-in attempts to connect to a new server in the list each time a unique request is received (that is, a request without a cookie).
    Note: The MaxSkips parameter has been deprecated as the MaxSkipTime parameter.
    See also here: http://download-llnw.oracle.com/docs/cd/E13222_01/wls/docs81/plugins/plugin_params.html
    You said the problem arises under significant load. Maybe, it is wise to tune the number file descriptor's on your operating system. HTTP connections are nothing more than TCP sockets on the operating system. All modern operating systems treat sockets as a specialized form of file access and use data structures called file descriptors to track open sockets and files for an operating system process. To control resource usage for processes on the machine, the operating system restricts the number of open file descriptors per process. You should be aware that all TCP connections that have been gracefully closed by an application will go into what is known as the TIME_WAIT state before being discarded by the operating system.
    On most unix systems you can use netstat -a | grep TIME_WAIT | wc -l to detemine the number of socket in time_wait state. You have to check with your system adminstrator how to tune the tcp_time_wait_interval. On solaris you can use: /usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval 60000

  • LDAP keep-alive connection ? (use of ldap_io_fns)

    Hi there,
    I am facing a new req. from network security guys that want to close 'idle' connections that crosses firewalls. But as I do use persistent search connection which are not very 'busy' => i.e. not enough traffic to be kept open by FireWall rule.
    Consequence my client could not 'detect' this cut of connection and do not receive any more the 'updates' through persistent search.
    I am now trying to init my connection setting optional io_fns structure changing the socket func by my socket func that do create a keep-alive socket.
    But it does not bind properly ... Init seem ok but bind never get out. LDAP receives bind and do log it but seem not able to respond properly ...
    Any idea on how to use this io_fns struct ?
    Many thanks.
    Hedi.
    .

    the problem is not that process is in foreground or background: the problem is the timeout: I need to avoid timeout, because the idea is to launch the report and then go out for lunch So I need to find a way in the code to advise the system that user has not to be logged out.
    Thanks
    Gabriele

Maybe you are looking for

  • IPod Touch 1st generation doesn't sync notes any more

    I have a 1st gen iPod Touch and 2 iPhones (4 and 4S). I use the iPod mainly for the gym, so I write my routines on the notes app. Now that I have updated my Mac to Mountain Lion and notes are out of Mail app, they don't sync. Does anybody know if the

  • When I try to open firefox it pops up, "do you want to allow changes to your hard drive" everytime

    Firefox update while I was trying to resolve a issue with a brother fax drive to update for windows 7, now every time I go to firefox it pops up, "Do you want to allow changes on your hard drive" as if it didn't finish, so I answer "yes", firefox bro

  • 10.4.3. and Address Book's SMS Integration with SE K750i

    Hi, This was a much loved feature in my Panther days and as such I totally cannot understand how, 3 updates later - in Tiger, Apple still hasn't gotten round to solving the "send SMS" feature in Address Book to work with Sony Ericsson K750i. I had th

  • Password Removal on my files

    My wife's employeer EFT her pay and sends her payroll stub via a PDF file that is password protected. Once I d/l it I want to remove the password protection. I've tried "save as" but that keeps the PW. Is there a way to save the file w/o the PW? Mike

  • Can i download oracle report server 9i

    hi i need oracle report server 9i , can i download it please help me . thanks mostafiz