Author Topic: Simulating custom peripherals?  (Read 31303 times)

Offline JuKu

  • Newbie
  • *
  • Posts: 14
    • View Profile
Simulating custom peripherals?
« on: September 08, 2009, 12:00:46 PM »
As noted in the filesystem replacement post, I am leaning towards picking Utasker for my next project, one of the main reasons being the really great simulator. However, the simulator obviously doesn't know about the peripherals in my project. How could I expand the simulator myself?

It is trivial to write something like

void AccessCustomDevice(...)
{
#ifdef _WINDOWS
  AccessSimulatedCustomDevice(...)
#else
  AccessRealCustomDevice(...)
#endif
}

The issue is how to write the AccessSimulatedCustomDevice(). It is up to me to decide how accurate simulation code I want to write (probably not very :) ), but how would I integrate that to the rest of the simulator? I am using Visual C++, and that is about the level I know how to do windows programming. However, the simulator isn't really a Visual C++ application. It does run under it and gives us a nice development environment, but there are no forms or other widgets. But maybe it is easily expandable? Am I hoping too much?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3240
    • View Profile
    • uTasker
Re: Simulating custom peripherals?
« Reply #1 on: September 08, 2009, 01:05:28 PM »
Hi

The simulator includes various 'standard' external devices as well as most internal peripherals.
When a new external device is required there are no guides to adding this since their requirements can vary greatly. However often it is worth investing a small amount of time in adding the necessary support so that you can benefit from accelerated project development and testing (as well as maintenance) later.

There are two basic simulations:
- in-line and interrupt driven

In-line ones return a value immediately and are generally easier to wire (certainly easier to explain...;-)

It may be better to describe more about the simulated device so that I could have a try at suggesting the best way to do this in this case.

Regards

Mark

Offline JuKu

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Simulating custom peripherals?
« Reply #2 on: September 08, 2009, 01:20:11 PM »
There is an IR remote. for that, a keyboard might be enough, but the customer might want to see a group of buttons. Then there is an on-screen display. On Visual C++, the RichTextBox component has (more than) enough functionality for that. There is also an existing processor, that I don't really know how to simulate, maybe a Form with buttons, checkboxes etc to set and retrieve the status and send messages when changed. There are also a few buttons and a maybe a potentiometer or a slider (and an LCD, but that is there already).

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3240
    • View Profile
    • uTasker
Re: Simulating custom peripherals?
« Reply #3 on: September 08, 2009, 01:59:34 PM »
Hi

If you communicate with the external micro-controller via UART you could connect the real micro to a COM port and possibly avoid the need to simulate any of its operation.

If you need to simulate test sequences the scrip based operation can be very useful. This allows pre-defined sequences of messages (eg. SPI, UART, port bits, etc.) to be played back (and repeated) to test standard cases and verify a project.
Note that there are not always examples in the project of these scripts and also the documentation is very limited at the moment, but bear in mind that this could be useful alternative/addition - there is a little example in the USB demo document (see page 15) showing USB frames being injected: http://www.utasker.com/docs/uTasker/uTaskerV1.3_USB_Demo.PDF


Regards

Mark


Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Simulating custom peripherals?
« Reply #4 on: September 08, 2009, 03:25:22 PM »
Just my 2 cents.

I needed to simulate connection to an external serial LCD display from CrystalFontz, this was easy to do I just wrote a crystal Fontz emulator as another uTasker Project and compiled it down to an exe. I then used com0com http://com0com.sourceforge.net/ to connect my new device to uTasker.

As for simulating inputs I modded the utasker simulator slightly to allow PC keyboard input to be routed through to my application see this post
http://www.utasker.com/forum/index.php?topic=634.0

Cheers

Martin

Offline JuKu

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Simulating custom peripherals?
« Reply #5 on: September 09, 2009, 07:19:21 AM »
Thank you! At first look, the com0com seems to be just what is needed for this task. Problem solved.

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Simulating custom peripherals?
« Reply #6 on: September 09, 2009, 11:00:23 AM »
Com0Com is brilliant I'm finding more and more uses for it.

I have permanently defined 3 serial port pairs on my computers (I use high numbers so I don't clash with anything)
COM100 <> COM110
COM101 <> COM111
COM102 <> COM112
And always connect my utasker projects to COM100, 101, 102 for Uarts 0,1,2

I've also used the terminal emulator Realterm http://realterm.sourceforge.net/ I'm using version V2.0.0.65 from here http://www.i2cchip.com/realterm/
Realterm has a bit of a clunky interface but the killer tool for me is that for a small donation you can get a spy driver that will allow you to spy on communications on a com port (Virtual or real). Another powerful tool to monitor serial port comms can be found here http://www.serial-port-monitor.com/

Lastly here's an interesting link showing how com0com or rather com2tcp can be used
http://logmett.com/forum/viewtopic.php?t=699

Have fun

Cheers

Martin

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Simulating custom peripherals?
« Reply #7 on: March 08, 2010, 05:37:12 PM »
Just Updating my previous post I've just found another good free serial port monitor called accessport see http://www.sudt.com/en/ap/index.html

I've attached a screen shot of a trace of a Modbus communication as an example



Offline Thomas

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Simulating custom peripherals?
« Reply #8 on: March 17, 2010, 04:17:28 PM »
Microsoft (ex NTinternals/Sysinternals) also have a free serial port monitor by the way, Portmon. You can find it here:

http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Simulating custom peripherals?
« Reply #9 on: December 13, 2011, 11:37:29 AM »
I Just thought I'd let people know that there is a Signed 64bit version of Com0Com available for those of you running windows7(64bit)

See http://sourceforge.net/projects/com0com/files/com0com/2.2.2.0/

Cheers

Martin

Offline jezc

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simulating custom peripherals?
« Reply #10 on: December 13, 2011, 10:11:38 PM »
Hi Martin,

Hurrah! I've been struggling to find a good way to get virtual com ports working in 64 bit Win7 Pro (the old unsigned Com0Com wouldn't install except in test mode...).

I'll give that a try again!

Thanks for letting us know :-)

Cheers
Jez

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Simulating custom peripherals?
« Reply #11 on: October 21, 2013, 08:45:36 AM »
Just to let people know a signed version of the COM0COM V3.0 driver is avaliable here https://code.google.com/p/powersdr-iq/downloads/detail?name=setup_com0com_W7_x64_signed.exe&can=2&q=

Regards

Martin Honeywill

Offline k64konfused

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Simulating custom peripherals?
« Reply #12 on: September 25, 2014, 03:53:22 PM »
Microsoft (ex NTinternals/Sysinternals) also have a free serial port monitor by the way, Portmon. You can find it here:

http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx

The only problem with PortMon is that it only works on Win 32bit systems.  It appears that AccessPort works on 64 bit systems, but I've yet to figure out how to make it actually capture data.  Martin, were you able to find any manual for this app?  My issue is that I'm coming from PortMon, which can access the COM port after it's been opened by the application that needs to be monitored.  I guess a discussion about this doesn't even belong in the uTasker forum -- not sure if you're okay with getting PMs about this...