I have success with my serial RS232 comms, but don't seem to be able to inject data at simulation time.
How much stuff do I have to go through in order to allow me to inject a serial string?
I did search around, but came up empty. Used to be easy in FC7 era.
Serial Simulation
-
- Posts: 133
- http://meble-kuchenne.info.pl
- Joined: Fri Dec 04, 2020 2:29 pm
- Has thanked: 26 times
- Been thanked: 7 times
-
- Matrix Staff
- Posts: 1921
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 623 times
- Been thanked: 645 times
Re: Serial Simulation
Hi
Injectors have been removed with V9, so now you don't have to add additional injector components to receive data.
Here are my properties to receive injected data:
I used the attached flowchart to send the data to the target device then the send part was disabled.
Injectors have been removed with V9, so now you don't have to add additional injector components to receive data.
Here are my properties to receive injected data:
I used the attached flowchart to send the data to the target device then the send part was disabled.
- Attachments
-
- UART Injector Test.fcfx
- (11.98 KiB) Downloaded 353 times
-
- Injector Test.png (365.23 KiB) Viewed 4430 times
Martin
-
- Valued Contributor
- Posts: 1462
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 136 times
- Been thanked: 713 times
Re: Serial Simulation
One way to do this (and I'm sure there must be an easier one....) is to use a virtual com port.
For example - I used the free trial from https://www.eltima.com/virtual-com-port-windows-10/
Then I create a pair of com ports (I had 13 -> 14) and connect FC Data source com port to 14... (it takes some time for the ports to show up if FC is running whilst they are created)
Then open 'putty' (or your favourite terminal program) on COM13 Then you can type whatever to the simulation com port (note that this step isn't required if the receive program is running on an MCU - as you can connect directly using 'putty')
The problem here is that the eltima software is expensive (there is a 14 day free trial). There are other virtual serial port programs available (some free) - though I haven't tried them.
Note that the 'logic' of the sample above means that the string received must be received in 10ms (so type fast) - or change the timeout on the ReceiveString function - or receive the data to a buffer and look for a 'termination' character (newline or no. characters received etc)
Martin
For example - I used the free trial from https://www.eltima.com/virtual-com-port-windows-10/
Then I create a pair of com ports (I had 13 -> 14) and connect FC Data source com port to 14... (it takes some time for the ports to show up if FC is running whilst they are created)
Then open 'putty' (or your favourite terminal program) on COM13 Then you can type whatever to the simulation com port (note that this step isn't required if the receive program is running on an MCU - as you can connect directly using 'putty')
The problem here is that the eltima software is expensive (there is a 14 day free trial). There are other virtual serial port programs available (some free) - though I haven't tried them.
Note that the 'logic' of the sample above means that the string received must be received in 10ms (so type fast) - or change the timeout on the ReceiveString function - or receive the data to a buffer and look for a 'termination' character (newline or no. characters received etc)
Martin
-
- Matrix Staff
- Posts: 1921
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 623 times
- Been thanked: 645 times
Re: Serial Simulation
With the attached Flowchart, you can type into the Human Interface RX Queue of the Console, while the simulation is running.
The LCD will show the chars as you are typing.
The LCD will show the chars as you are typing.
- Attachments
-
- UART Injector Test2.fcfx
- (12.94 KiB) Downloaded 417 times
Martin
-
- Valued Contributor
- Posts: 1528
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 353 times
- Been thanked: 549 times
Re: Serial Simulation
Hi Martin
If I'm not mistaken I think they're referring to FC not being able to simulate a Receive Interrupt.
Having used this interrupt many times to populate the CB I'm quite familiar with it and know it works (at least in my applications). In simulation, if an Injector could directly populate the CB then that would negate any need for an Interrupt to do so and would maybe be quite an easy component / feature to include?
Whilst learning about the CB I used to include a push button that was polled in the main loop. If pressed (simulating my interrupt) it would branch and populate the CB with whatever test string I chose. The main loop (which polled the CB) would then react. My test string(s) would include junk messages and of course the proper one(s) too thereby ensuring correct "polling" of the CB.
Regards
If I'm not mistaken I think they're referring to FC not being able to simulate a Receive Interrupt.
Having used this interrupt many times to populate the CB I'm quite familiar with it and know it works (at least in my applications). In simulation, if an Injector could directly populate the CB then that would negate any need for an Interrupt to do so and would maybe be quite an easy component / feature to include?
Whilst learning about the CB I used to include a push button that was polled in the main loop. If pressed (simulating my interrupt) it would branch and populate the CB with whatever test string I chose. The main loop (which polled the CB) would then react. My test string(s) would include junk messages and of course the proper one(s) too thereby ensuring correct "polling" of the CB.
Regards
-
- Matrix Staff
- Posts: 1921
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 623 times
- Been thanked: 645 times
Re: Serial Simulation
Hi
The Flowchart I posted was only to work with simulation, not hardware.
I just wanted to establish if entering data on the console was what Alan was after.
If it was then I would then create a flowchart that works in simulation and hardware.
It would use an RX interrupt, circular buffer & LCD control.
For example, sendand the LCD is cleared.
Sendand the chars are printed on the next row of the LCD.
I have now decided the flowchart would come in handy as it works with both simulation and hardware, So I have uploaded it.
The secret is to use IsSim component to enable a timer interrupt within simulation only.
The timer interrupt will call the RX interrupt macro.
It's important the timer interrupt does not call the RX interrupt macro on hardware.
In simulation mode the characters are entered within the Human Interface RX Queue of the Console
What I have noticed is you need to click on the blank area of the Human Interface RX Queue once, enter the char and then click on the blank area for the second time.
You then should be good to keep typing chars from your keyboard.
As soon as you type a char, it will disappear as it is being received within the CB via RX ISR user macro.
The Flowchart I posted was only to work with simulation, not hardware.
I just wanted to establish if entering data on the console was what Alan was after.
If it was then I would then create a flowchart that works in simulation and hardware.
It would use an RX interrupt, circular buffer & LCD control.
For example, send
Code: Select all
#
Send
Code: Select all
;
I have now decided the flowchart would come in handy as it works with both simulation and hardware, So I have uploaded it.
The secret is to use IsSim component to enable a timer interrupt within simulation only.
The timer interrupt will call the RX interrupt macro.
It's important the timer interrupt does not call the RX interrupt macro on hardware.
In simulation mode the characters are entered within the Human Interface RX Queue of the Console
What I have noticed is you need to click on the blank area of the Human Interface RX Queue once, enter the char and then click on the blank area for the second time.
You then should be good to keep typing chars from your keyboard.
As soon as you type a char, it will disappear as it is being received within the CB via RX ISR user macro.
- Attachments
-
- UART Injec Test With CB.fcfx
- (20.08 KiB) Downloaded 464 times
Martin