From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication - A simulator based on request msg from other device, it should send response.

Solved!
Go to solution

Hi,

 

I want to create a simulator, which checks the request msg received from other devices via serial port and based on the request simulator should response msg.

For example: 

Other Device Request to my simulator  : 2B 2B 2B

My Simulator  Response : 65 6E 74 72 61 4E 45 54 3E 20

Also, there are series of request message send sequentially to the simulator and after response is sent by simulator for each request - login successful.

 

Any heads up on how to proceed is highly appreciated.

 

Thanks

0 Kudos
Message 1 of 11
(4,192 Views)

I would recommend a sort of state machine.  Each step in the state machine is to look for the message.  Do you have a better description of the full message protocol?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 11
(4,168 Views)

Hi Crossrulz,

 

It is a serial data protocol and data are in ASCII format.

Can you post a simple vi if possible for my better understanding, so that i can take it up from there.

 

 

Thanks

Aniket

0 Kudos
Message 3 of 11
(4,160 Views)

aniketjha wrote:

It is a serial data protocol and data are in ASCII format.


That is a start.  Do the messages you receive end with a termination character (typically a Line Feed, 0xA, \n)?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 11
(4,152 Views)

Yes, it ends with termination character...

0 Kudos
Message 5 of 11
(4,149 Views)
Solution
Accepted by topic author aniketjha

I originally wrote this for a nugget series that I have been working on here in there.  Should at least get you started.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 11
(4,139 Views)

Thanks Crossrulz, this will work.

 

I will let you know once i done with the vi.

0 Kudos
Message 7 of 11
(4,126 Views)

Hi Crossrulz,

 

1 simple doubt i have and it is not related to this topic, is there any way i can provide enable/disable button to create/clear communication loss via serial port.

 

Sorry for pulling up this simple question in this thread.

 

Thanks

Aniket

0 Kudos
Message 8 of 11
(4,120 Views)

You can use a State Machine with states like "Connect", "Read", "Close", etc.  So when you detect a connection loss, you can go back to the Connect state or an idle state waiting for somebody to press a button to reconnect.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 11
(4,107 Views)

I am actually new to this Crossrulz, if i get some sample vi on state machines particular to my requirement i will pick it up from there.

 

 

Aniket

0 Kudos
Message 10 of 11
(4,103 Views)