/*@!Encoding:1252*/
variables
{
  byte gIsSleeping; // indicates current mode (Sleep/Awake)
}

on sysvar LIN::Master_SyncBreakLen
{
  linSetBreakLength(@this, @LIN::Master_SyncDelLen);
}

on sysvar LIN::Master_SyncDelLen
{
  linSetBreakLength(@LIN::Master_SyncBreakLen, @this);
}

on sysvar LIN::Master_InitTime
{
  linSetWakeupParams(@this, 1);
}

on sysvar LIN::Master_SendSleepCmd
{
  if (0==gIsSleeping)
  {
    linSendSleepModFrm(0, 0, 0xff);
    gIsSleeping = 1;
  }
}

on start
{
  if (IsSimulated()) // simulated mode is currently not supported
  {
    WriteLineEx(0, 3, "This demo cannot run in simulated mode!");     
    stop();
  }

  gIsSleeping = 0; // on measurement start the system is awake
}

on sysvar LIN::Motor1_SendWakeup
{
  // Just drop the indicator flag here. The actual wakeup frame is sent by Slave
  gIsSleeping = 0;
}

