RS232 Listener

Hi,
Currently, I am transmitting data via RS232 serial port, but i am wondering when the RS232 queue has new data avaliable for my application, should i use to a Listener (e.g. ActionListener) to proceed reading in the new data? OR should i check the queue periodically?
Pls kindly advise me. Thks

If you are using the JCA you should take a look at the example SimpleRead.java in the Java Communications API Users Guide: http://java.sun.com/products/javacomm/javadocs/API_users_guide.html
Søren

Similar Messages

  • Design problem: RS232 communication

    Hi,
    I have a design problem for communication with a device via RS232. Since I'm normally a C++ programmer I might just look at the problem from a wrong angle and hope for some hints how to do it in LabVIEW.
    The scenario:
    A device is communicating with the PC via RS232. The device permanently sends data packets. At the same time, commands can be sent to the device and it returns replies. Data packets and reply packets are arbitrarily mixed, i.e. after sending a command there could be a couple of date packets before the reply comes back but the packets can be distinguished by an identifier.
    At least one, ideally several VIs should communicate with the device. Commands should be sent by pressing buttons and the incoming data should be parsed (the packets contain mutliple data streams) and shown on graphs or saved to files.
    My initial idea:
    Coming from C++ I wanted to build a class for the communication that permanently reads the incoming data and splits it to reply and data packets. This class would then have a function to send out a command and would return the reply or a timeout and it would be possible to register and unregister listeners (I wanted to use queues for this) for the various data streams.
    The problems I ran into:
    There were a couple but the two most pressing problems were: how could I communicate with the constantly running sample VI (e.g. to stop sampling) and how could I propagate changes to the class to it (e.g. new listeners). Since it is not returning I don't see a good way to implement it as in instance funcion (i.e. pass it the object). I could probably not let the sample function run continously but call it periodically from outside. However I planned to implement the class as a singleton, so it could be used parallely from different VIs.
    Is there a best practice for a case like this?
    I'm glad about any hints or ideas.
    Thanks,
    Tobias

    tfritz wrote:
    Hi,
    thanks. Since almost the same thing was suggested to me in a German forum I guess this is really common practice (using one VI with different methods controlled by a queue). It still seems a little "unnatural" for me but my biggest concern (bad interface description) was shattered by the suggestion in the link you sent me to wrap these functions with wrapper VIs, thus caller VIs won't have to deal with the call-by-queue-mechanism. This might also be easier to port to a different implementation later. However I still see the danger that the continously running VI could easily become bloated. 
    It also requires me to change the way I have looked at VIs until now. In our course they told us that VIs are basically functions. Using this design patterns, the VI becomes more of a module, really (Like a C module implemented in a C-Source file). But I will try it. It sounds as if it could work.
    I will still look into the OOP solutions a little more, though. Do I understand you correctly that you wouldn't recommend using LVOOP because it's still buggy? What about dqGOOP for example? This sounds like it could do what I need (however it doesn't seem to implement things like polymorphism, late binding and inheritance so I don't quite see what's so OOP about it. It seems more like programming with structures in C.)
    I don't know if LVOOP is buggy or not.  I think early on it was buggy and things have improved in recent versions. I have read that it doesn't have all the features that you would have in OOP like C.  I wouldn't recommend it only because I'm not familiar with it at all.  I can't recommend something that I'm not comfortable with.  If you go that route, plan on spending time in these forums and in LAVA to reading up on what others have done.  I haven't hard of dqGOOP.
    But back to your suggestion. I still have a couple of questions:
    - How do you return values from the module? Would you use a queue for that as well?
    - Where would the parameter queue be held (created and passed to the VI)
     I would store all of these in a functional global variable.  This is the VI that stores data in shift registers.  Ben's action engine nugget is an advancement on that.  This allows for both the calling VI and the parallel running subVI to get and set the data as needed.  It runs quickly so neither process should be forced to wait while the other  VI is doing its thing.
    - My VI has to be constantly sampling and this shouldn't be interrupted too long by other functions as adding a listener. However both functionalities have to access the same kind of data. Is there an easy way to parallelize this? Would the sampling be a case in the case diagram that's always used if no command was sent to the VI or would it somehow run parallely?   Yes.  There are a couple of ways of doing this.  One would be for the dequeue to have a timeout function.  In the event the dequeue times out, you run the code that is doing the acquisition.  I think a better method is that the code that does the acquisition enqueues its own command again to the end of the queue.  Let's say that is command A.  So when case A finishes, it enqueues A, which seeds itself to run again.  So if nothing else comes into the queue, it just executes A , A, A, A.  But let's say another section of code needs to do something such as command B.  It will slip B into the queue while A is executing.  So you would A, B, then A again, because A would get slipped back into the queue when the first A finishes, but B has already been put in while the first A was running.
    - Would it be possible to make the VI reentrant and in this way use it simultaneously on different COM ports (using different parameter queues as well)? I'm not sure if I will need this but it would be neat if it could work.
    I think you could do this.  It may be a case where the VI is saved as a template  (.vit) and you initiate it multiple times.  I haven't needed to do this before, so I'm afraid I can't provide any details or useful tips. 
    Well, I will fool around some more. Thanks so much for your help. This is kind of exciting since the concepts are quite new for me. Btw, is there something like an academic theory (computer science) for LabVIEW? I came across functional languages in university but data flow languages are still a new concept for me.
    Tobias
    tfritz wrote:
    Another question about the "dynamically starting" of the VI:
    How is the path handled? Is it guaranteed that it always takes the VI from the project or does it just search for the first VI by that name it finds in the file structure? Does this still work when building an .exe from the project? What happens if the VI is already running? Can you test for this?
    While I'm at it: is there a way to stop LabVIEW from searching for subVIs it can't find when openin a VI? This resulted in very unexpected behaviour sometimes where it would find the VI somewhere else (with the same name but maybe an older version).
    In my case, I just had the path hardcoded.  It is my only instance, I'm not planning on moving the VI's.  If you don't have the path, it will take a VI by that name if it's in memory.  If it isn't in memory, it starts searching relative to the calling VI's path.  One thing I know, if you are dealing with relative paths, a subVI has a different relative path in an .exe as opposed to the development environment.  The name of the .exe becomes a folder.  So in development, if your sub VI is mySubVI.vi.  In an executable, its path is MyExe.exe\MySubVI.vi
    For all of this, I recommend searching the forums to get more details.
    If it is searching for a VI, you can hit ignore.  But of course you'd have to do it before it finds it.  When you are dealing with versioning issues, I recommend making a backup copy of the entire directory structure elsewhere.  Some location where it shouldn't stumble across it.

  • Rs232 communications with usb rs232

    This is my problem. I am trying to log communication over rs232.
    I use an standalone laptop with runtime and a built application, installed on this is an usb to 4 rs232.
    I use the serial port read.vi.
    The only thing i get out is when i set the string indicator to /code. and then i get alot of number, letters and symbols.
    its not hex becuse hex isnt using %+ and )
    anyone got a solution to this or a even a guess.. i am running out of things to try.
    /Mattias

    What are you trying to log from?   Is it possible that the device that you are listening to is speaking binary and you may need to convert the format?
    Paul <--Always Learning!!!
    sense and simplicity.
    Browse my sample VIs?

  • TCP Listen only accepts 1 packet

    Hello,
    I am trying to create a RS232 to TCP/IP converter VI. I am trying to use this VI to allow my main VI to communicate with a microcontroller (using rs232) over a network and I do not have access to a hardware converter.  The VI works great for sending data from the microcontroller ( rs232 -->TCP) but I am having problems getting information to the microcontroller (TCP --> rs232). I have tried numerous server configurations using the TCP Listen and Create Socket. For some reason I can only seem to receive a packet when using TCP Listen and no while loop but then it only receives 1 packet and none after that. I have used other programs to verify that the main VI is correctly sending the packet to that port and have verified that the problem is in this VI. 
    The following image is the "working" version that only receives the first packet sent to it 
    The following two pictures are the other configurations I've tried but they receive no packets.  
    TCP Listen with while loop 
    TCP Wait on Listener
     If you can provide any help it will be much appreciated.
     Thank you,
                 meanmon13
    Solved!
    Go to Solution.

    Those wont work because you aren't thinking dataflow. Dataflow means each piece will execute when all the inputs to it are available. Your first while loop runs forever. There is an input to the second while loop coming from the first while loop. Hence, it will never get to your second while loop, and thats why you aren't receiving anything.
    Put everything in one loop and use error wires to control the order
    Message Edited by for(imstuck) on 06-09-2010 11:26 AM
    CLA, LabVIEW Versions 2010-2013

  • 1 event listener, many events source

    i have 3 different classes. 2 listens for read() from RS232, while 1 listens for read() from a socket
    When any of the 3 registers a read, i will need to fire a thread with inputs from the event that processes my business logic
    Most probably i will need a listener that reacts to any of the 3 events after which, spunning a thread to handle the inputs from the event and
    then in a forever loop to continue to wait for new events
    From what i've read, it seems that i will need a EventListener that listens to the 2 RS232 events and 1 Socket event
    I am pretty new to the whole event listener concept, is there any reference code that i can take a peek at?
    Many Thanks

    There's no reason why the same EventListener can't be added to serveral event sources. (That's why there's a getSource() in the EventObject class).

  • Object serialization over an RS232 port

    Hi
    Thanks in advance for any help!!!
    I have just started embarking on a java project that incorporates both J2SE and J2ME technologies.
    In short:
    I am developing an embedded java system using a JStamp development kit. In conjunction to this I am also developing a java pc GUI application that is used for setting up a configuration for my embedded system.
    So here�s what I want to do.
    Firstly I would like to input a configuration via my java pc GUI application, and then once this configuration is complete I would like to wrap it in an object. Once the object has been created I would like to serialize it and send it over an Rs232 port as some kind of �OutputStream�. I would expect my embedded system to be listening to its serial port for this stream and then once received reconstruct the stream into it�s original object. The embedded system would then replace its current configuration with the new object.
    Questions:
    1.What kind of data streams and filtering streams will I need on the java pc application side (or how can I program these streams myself?)?
    2.How can I reconstruct this serialized object at the embedded system side

    From the javadoc:
    Multiple references to a single object are encoded using a reference sharing mechanism so that graphs of objects can be restored to the same shape as when the original was written.
    This means ObjectOutputStream writes each Object instance once. It tracks instances which have been written and if they are written again, it only sends a "reference" to that object. This serves 2 purposes: 1) most importantly, preserves the integrity of the object graph and 2) reduces the amount of data.
    Two techniques to solve this:
    1) open a new stream each time
    2) use the reset method

  • How do i use my Platronix bluetooth with iPhone 4 to listen to music.

    How do i use my Platronix bluetooth with iPhone4 to listen to music.
    Its a mono bluetooth paired with the phone.
    I dont want to buy a new stereo headset but can i use this same one.

    One way is to sync the contacts from the old iPhone to iCloud. Then when you turn on the new phone and set it up for iCloud and turn on the Contacts in Settings >iCloud, they will come to the new phone. http://www.apple.com/icloud/setup/

  • APEX LISTENER Install troubleshooting

    Hi, I need help.. :-)
    Default Database connection not configured properly
    What I have done:
         ALTER USER APEX_LISTENER ACCOUNT UNLOCK;
         ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK;
         ALTER USER APEX_REST_PUBLIC_USER ACCOUNT UNLOCK;
         connect APEX_LISTENER/mypasswd1
         connect APEX_PUBLIC_USER/mypasswd2
         connect APEX_REST_PUBLIC_USER/mypasswd1
    Check default.xml
    password: replaced encrypted one with clear text one for APEX_PUBLIC_USER to ensure it is correct
    even tried APEX_LISTENER password just incase
    Is there a simple JDBC test to see if it connects? it is APEX_PUBLIC_USER who is connecting isn't it?
    ======================================================================
    java -jar apex.war
    Feb 22, 2013 12:44:40 PM oracle.dbtools.standalone.Standalone execute
    INFO: NOTE:
    Standalone mode is designed for use in development and test environments. It is not supported for use in production environments.
    Feb 22, 2013 12:44:40 PM oracle.dbtools.standalone.Standalone execute
    INFO: Starting standalone Web Container in: /data/oracle/orawd/product/11.2.0/dbhome_1/apex_listener/apex
    Feb 22, 2013 12:44:41 PM oracle.dbtools.standalone.Deployer deploy
    INFO: Will deploy application path = /data/oracle/orawd/product/11.2.0/dbhome_1/apex_listener/apex/apex/WEB-INF/web.xml
    Feb 22, 2013 12:44:41 PM oracle.dbtools.standalone.Deployer deploy
    INFO: Deployed application path = /data/oracle/orawd/product/11.2.0/dbhome_1/apex_listener/apex/apex/WEB-INF/web.xml
    Feb 22, 2013 12:44:41 PM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
    INFO: Using configuration folder: /data/oracle/orawd/product/11.2.0/dbhome_1/apex_listener/apex
    Default Database connection not configured properly
    Feb 22, 2013 12:44:42 PM oracle.dbtools.rt.web.SCListener contextInitialized
    INFO: Oracle Application Express Listener initialized
    Application Express Listener version : 2.0.0.354.17.06
    Application Express Listener server info: Grizzly/1.9.49
    Feb 22, 2013 12:44:42 PM com.sun.grizzly.Controller logVersion
    INFO: GRIZZLY0001: Starting Grizzly Framework 1.9.49 - 2/22/13 12:44 PM
    Feb 22, 2013 12:44:42 PM oracle.dbtools.standalone.Standalone execute
    INFO: http://localhost:8888/apex started.

    That could be a problem.
    I was answering the question:
    BillC wrote:
    Is there a simple JDBC test to see if it connects? it is APEX_PUBLIC_USER who is connecting isn't it?Yes - APEX_PUBLIC_USER is the connecting user.
    You can use SQLPLUS to make sure you have the correct password.
    After that, it is the SERVER, PORT, SID/SERVICE in the APEX listener you need to confirm.
    You can TNSPING to confirm you have the correct selections for those.
    You can always re-run the java -jar apex.war setup command to all of the basic settings.
    The reason I mention that is because if you modify the settings manually - we need to ask "which file?" because there is the default and the database specific one too.
    Try making a request to the service in standalone mode and you should get a terminal output (the window stays open) with a more detailed error. I would guess there will be an ORA-12514, TNS listener does not currently know of service requested in descriptor or something similar that will give you the "debug" information you are looking for.
    Regards,
    --Tim St.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem with logging in to apex application builder listener

    I have problem with my settings and am posting this in hope that someone else out there had similar problem and solved it!
    I am trying to use reverseproxy to access to our db through apex listener.
    It's been all set-up and I can login to the application it self either through proxy or no proxy using the listener.
    But when I try to login to apex application builder I cannot do it through proxy(with no proxy, it works).
    It just refreshes the login page when I click login....
    I tried to upgrade the listener to the latest v1.1(using 1.0.2) but it causes my tomcat to crash...
    So solution i am looking for is how to make logging in work through proxy..
    In the firebug it is showing that below and few other request status as 302 moved temporariry
    http://myserver:8080/testsin/apex/wwv_flow.accept
    Where as with no proxy it is saying Found.....
    Any thoughts??
    Thanks
    Sin K

    Hello Sin K,
    so proxy and Tomcat are located on different machines as well? Is the proxy able to commuicate with the Tomcat on the configured internal ports and is the proxy able to lookup the hostname you configured for the Tomcat?
    For the connector, the proxyName and proxyPort should be the parameters the client uses to call APEX. So if your clients should call via http://proxyserver:8080/testsin/apex the settings would be
    proxyName=proxyserver
    proxyPort=8080Reason for this is that applications (e.g. the APEX Listener) generate there URL references with these parameters.
    But does your proxy actually serve on port 8080? And is that port accessible by clients? Do clients accept cookies from that server?
    In my case, there is only one 302 which redirects to http://host:port/apex/f?p=4500:1000:sessionid which is correct.
    If you look into your first post request in firebug, what's in the request header?
    -Udo

  • Making an iTunes library protected against ripping onto CD, listen only

    Hi there
    we have a security issue with itunes. We are a secure college within an HMP&YOI and we use 16 imacs in two rooms. We have installed the same master music library (currently 8500 tunes)on each machine and all students have access to it under their own account.
    Our problem is this. 1 (How) is it possible to make a library read only, i.e. so it is not burnable onto a CD, for copyright protection. We want the lads to be able to hear the music without being able to 'rip' it to CD.
    2. Is it possible to split the library into two libraries, making the content of one burnable and the content of the second not burnable. This way we can offer them instrumentals and original titles for burning and commercial copyright protected titles for listening only.
    NB None of the content has been downloaded from the itunes store.
    Your help on this matter would be very much appreciated.
    Mark Anderson
    Music dept
    HMP & YOI Ashfield

    Hi Patrick
    Your solution to the problem seemed to be the answer but I now have another problem: not all the macs in the music room can 'see' i.e. share the new intel mac.
    They are all connected via a Belkin switch using ethernet and sharing is enabled in all machines. Some of the iSite white iMacs can be seen by the new intel mac but they cannot 'see' the new intel mac. How can an ethernet connection work only one way ? We are using standard ethernet two way cable. All machines are running 10.5.3 apart from the new mac which is happy running 10.4.11.
    If I could get all the macs in the room to 'see' the new intel machine, then we could run the intel machine as the Master iTunes Library and share it as you suggest 'read-only' to the other machines.
    Has anyone any suggestions as to why this is happening ? Is there something other than turning sharing on in system prefs that one has to do to enable two communication between all machines ?
    Thanks
    Marco

  • How do I use home sharing between my home computer and my work computer so I can listen to the same music both places?

    Hello. I am trying to use my work computer with itunes to listen my my music on my itunes on my computer at home. I have signed into both. My computer at home is off, is there a way to listen to all my music on both computers by using Home Sharing or another means?

    The best way I know is to sign up for iTunes Match.  All your music is stored in the cloud and can be accessed by up to 10 devices.

  • How to configure oracle listener profile for multiple oracle database

    Hi,
    I am going to install solution manager system in the same server of ERP EHP4 on Windows. Both DB are oracle.
    I'd like to know how to configure listener in this kind of envirnmonent.
    a. use two listener and different ports
    b. use same listener but different ports
    c. use same listener and same port
    Which is the correct mothed?
    And, after installation, there seem three set of profiles of listten, one for ERP, one for SLM, and the other for OS?(%windir%system32), which one is functional?
    Please advise.
    Thanks a lot.
    Regards,
    Alex

    Hi,
    standard installation is creating new configs for listener for each instance.
    I would recommend to use one listener per each instance.
    YOU CAN NOT HAVE one port number for two differnet systems!
    If you want to use one listener than you must adapt tnsnames.ora, listener.ora and ensure that both systems will use different port numbers.
    For example PORT= 15<system number>
    Peter

  • Is there a way that iTunes can act as a Radio Alarm Clock? I have found the radio station I enjoy listening to in the iTunes Radio List. Is there anyway iTunes (and my Mac) can be set to come-on and start playing that Radio Station from Sleep mode at spec

    Is there a way that iTunes can act as a Radio Alarm Clock?
    I have found the radio station I enjoy listening to in the iTunes Radio List. Is there anyway iTunes (and my Mac) can be set to come-on from Sleep mode and start playing that Radio Station at specific times of the day?
    Any App or plug-in that does that?
    Many thanks
    Kevin

    Turning your Mac into a clock radio.
    1.  In iTunes create a playlist that contains just the radio station you want to wake up to.
    2.  Export the playlist (as .m3u works well).  Get Info on your playlist file and look at the Open With entry to make sure it points to iTunes, VLC or some other app that will stream your station.
    3.  In iCal create an event entry at the time you want to wake up.
    4.  Right (or Control) click on your wakeup event and select Get Info.
    5.  For "alarm" select Open File.
    6.  Now under Open File there will be a place to add the file to open.  It will probably be some default entry (like iCal).  Click on it will allow you to select "other."  Then use the file dialog to select your playlist file.
    Your Mac will wake you up at the appointed time.  You don't need to keep iCal running.  If you want to put you Mac to sleep for the night then there is one more thing you need to do.  Open System Preferences to Energy Saver and click on the Schedule button.  Check Start up or wake and set the wake up time to slightly before your iCal alarm time.
    Dan

  • Please help me. I have an IBook g4 and I've somehow lost plugins that I need to listen to webcasts etc. I've tried to download them when it signifies to "download appropriate plugin" or whatever it says, and when i hit the button, it says  "no suitable...

    PLEASE, PLEASE HELP ME. I'm a computer ignorant woman and need help. I have an IBOOK G4 and I was trying to fix a problem in IPhoto (which never got fixed) and took some guy's bad advice to reset iphoto or something and now my plug-ins are gone too. Or at least the one(s) that were allowing me to listen to on-line discussions and audio recordings.. Can anyone help me? I have gone to UPDATE SOFTWARE and updated Java but that is all.  It's like I go to a think were there is an audio thing to listen to and there is a picture of a plug in and it says something like "Plug in not available to listen to this" and then gives you an option to download plug-in but when I do, it says something like "No Plug in was found that was useable" or something alone those lines. Then it has a manual plug-in option but when I clicked that, I entered the frustrated crying zone. Can you help?  I will so give you big points!   Thank you!

    THis is all Greek to me, but maybe it answers your questions????  Thank you Ronda.
    ATA Bus:
    MATSHITADVD-R   UJ-845E:
      Model:    MATSHITADVD-R   UJ-845E
      Revision:    DMP2
      Serial Number:   
      Detachable Drive:    No
      Protocol:    ATAPI
      Unit Number:    0
      Socket Type:    Internal
    Built In Sound Card:
      Devices:
    Texas Instruments TAS3004:
      Inputs and Outputs:
      Internal Microphone:
      Controls:    Left, Right
      Playthrough:    No
      PluginID:    TAS
      Headphones:
      Controls:    Mute, Left, Right
      PluginID:    TAS
      Internal Speakers:
      Controls:    Mute, Left, Right
      PluginID:    TAS
      Formats:
    PCM 16:
      Bit Depth:    16
      Bit Width:    16
      Channels:    2
      Mixable:    Yes
      Sample Rates:    32 KHz, 44.1 KHz, 48 KHz
    PCM 24:
      Bit Depth:    24
      Bit Width:    32
      Channels:    2
      Mixable:    Yes
      Sample Rates:    32 KHz, 44.1 KHz, 48 KHz
    DIMM0/BUILT-IN:
      Size:    512 MB
      Type:    Built-in
      Speed:    Built-in
      Status:    OK
    System Power Settings:
      AC Power:
      System Sleep Timer (Minutes):    6
      Disk Sleep Timer (Minutes):    10
      Display Sleep Timer (Minutes):    6
      Dynamic Power Step:    Yes
      Reduce Processor Speed:    No
      Automatic Restart On Power Loss:    No
      Wake On AC Change:    No
      Wake On Clamshell Open:    Yes
      Wake On LAN:    No
      Wake On Modem Ring:    Yes
      Display Sleep Uses Dim:    Yes
      Battery Power:
      System Sleep Timer (Minutes):    9
      Disk Sleep Timer (Minutes):    10
      Display Sleep Timer (Minutes):    9
      Dynamic Power Step:    No
      Reduce Processor Speed:    Yes
      Automatic Restart On Power Loss:    No
      Wake On AC Change:    No
      Wake On Clamshell Open:    Yes
      Wake On Modem Ring:    No
      Display Sleep Uses Dim:    Yes
      Reduce Brightness:    Yes
    Battery Information:
      Battery Installed:    Yes
      First low level warning:    No
      Full Charge Capacity (mAh):    466
      Remaining Capacity (mAh):    466
      Amperage (mA):    0
      Voltage (mV):    16491
      Cycle Count:    247
    AC Charger Information:
      AC Charger (Watts):    50
      Connected:    Yes
      Charging:    No
    Hardware Configuration:
      Clamshell Closed:    No
      UPS Installed:    No

  • Will I be able to copy my music library from my PC to I pad and listen to it at a remote place without sync and without I tunes match?

    Will I b able to copy my music library from PC to I pad while sync and listen to it without sync at a remote place. Is it possible without iTunes Match?

    Yes. As long as all your songs you lost have been Matched or Uploaded to iTunes Match you can download your entire library from the cloud.
    It might take some time though

Maybe you are looking for