TCPmaker : Visual Tour    Exploring and Customizing the Generated Code  

You may recall that in the previous tutorial, we compiled and ran the code that was generated for this PICDEM.net2 board, without adding any code of our own to do anything with data sent from the PC, or any code to send any data from the device IN to the PC.

When we ran the device, one of the indicator lights on our PC browser layout blinked, as if some ghost was pressing one of the switches on our PICDEM.net2 board, even though we hadn't actually added any code yet to read any of the switches on our board.

How did that happen?

That happened because TCPmaker adds some special "Blink" code to the mtEndOfMessage() handler, to let you know that your device is alive and well. Here is what that code looks like for this specific project:

// - - - - - Start of Initial Testing Code - - - - -
// The following Testing Code is generated for the sole purpose of testing
// your generated TCPmaker code. It causes at least one control on the index
// page of your TCPmaker layout, as displayed on the browser, to change
// repeatedly, so you can see that your device is actually communicating
// with the PC browser.
// Once you have tested the generated TCPmaker code, you will want
// to remove this Testing Code and replace it with something meaningful
// for your project.
// Testing Code: Change something every 0.5 seconds
if (!BlinkCounter)
  // Toggle Integer Variable Btn1 to cause something to blink
  Btn1 ^= 1;
  Btn1TxFlag = 1;
  // Restore BlinkCounter
  BlinkCounter = 6;
// - - - - - End of Initial Testing Code - - - - -

In this project, TCPmaker selected Btn1, an Integer Variable that is associated with an Ld (colored LED Indicator Control) on your PC Browser layout, and generated code to change this variable's  value (in this case, by toggling between 0 and 1) every 0.5 seconds. This causes the Ld control to blink on the PC browser display.

TCPmaker looks at the Variables and Controls that you have on the default ("index") page of your layout, and chooses one to make a control blink or change. If TCPmaker has to choose a variable that is associated with a gauge, it will cause the gauge reading to increase slowly until it reaches its maximum value, then it will wrap to 0 and begin increasing again.

As the comments state, this "blink" code is only intended for initial testing: we expect that you would disable it or delete it as soon as you start adding your own code to what TCPmaker has generated for you.


19 of 21
Copyright Notice and Author Information