Jump to content

Best solution for Ethernet or Serial communication


Recommended Posts

Hello to everybody,

I'm looking for the best programming solution to be implemented in an ethernet and/or serial communication.

I attach an image of the sketch of the two solution I've thought.

Let me know which of them is the best and/or if there is something better.

Thanks

Max

post-787-0-90042800-1299231950_thumb.jpg

Link to comment

If you're looking for architecture suggestions, what's wrong with the standard queue driven state machine? You can have an Init case, and close case that can be used to restart the driver if there is an unexpected crash. With a sequence architecture like both of your examples, there isn't any way to perform a close and restart operation (maybe in the bottom one but I still don't like it). If you want to stick with simple I would suggest using the top option, but replace the while loop with a while loop and an event structure in it, so there doesn't need to be polling for controls, but you also have a timeout for reading if desired.

Link to comment

If you're looking for architecture suggestions, what's wrong with the standard queue driven state machine? You can have an Init case, and close case that can be used to restart the driver if there is an unexpected crash. With a sequence architecture like both of your examples, there isn't any way to perform a close and restart operation (maybe in the bottom one but I still don't like it). If you want to stick with simple I would suggest using the top option, but replace the while loop with a while loop and an event structure in it, so there doesn't need to be polling for controls, but you also have a timeout for reading if desired.

Thanks, this was my goal.

I will choose the first solution with the event structure because of I'm not so familiar with the state machines.

Max

  • Like 1
Link to comment

Thanks, this was my goal.

I will choose the first solution with the event structure because of I'm not so familiar with the state machines.

Max

I would recommend against that. Take the time to learn how to use state machines. They are much more flexible and much easier to maintain. I would definitely avoid using sequence frames in any form or fashion. They are not a recommended construct and generally should only be used to impose data flow where none exists. Even then, this should be limited to a single frame with a small bit of code. State machines are not that difficult to learn and they are a very powerful tool.

Link to comment

I would recommend against that. Take the time to learn how to use state machines. They are much more flexible and much easier to maintain. I would definitely avoid using sequence frames in any form or fashion. They are not a recommended construct and generally should only be used to impose data flow where none exists. Even then, this should be limited to a single frame with a small bit of code. State machines are not that difficult to learn and they are a very powerful tool.

Thanks Mark,

at tha moment I find easier to use one of the two solution posted, but I'm studying in order to implement the state machine solution asap.

Bye

Max

Link to comment

I use a state machine that has two parallel loops in the meat of it. If the connection is lost, it will attempt to reconnect on a separate port. The code for the connect is in separate states of the state machine.

The screen shots show the cRIO TCP Server run state and the HMI TCP Client run state.

Let me know if you have any specific questions. I am limited to what code I can share but am can at lease offer screen shots.

post-2002-0-76962100-1299860470_thumb.jp

post-2002-0-89180300-1299860615_thumb.jp

Link to comment

Thanks Mark,

at tha moment I find easier to use one of the two solution posted, but I'm studying in order to implement the state machine solution asap.

Bye

Max

The reason I am strongly suggesting state machines is that they are not that difficult to implement (essentially a case structure inside a while loop) and that both ways you are proposing are considered poor choices in LabVIEW. Better to begin learning the preferred methods than to establish bad habits using the poor choices. It becomes difficult to "unlearn" how to do something.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.