Page 1 of 1

Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Wed 28. Aug 2024, 11:34
by iso32
Hello,

I am using the PLIN USB with PLIN view Pro. I have connected the power and LIN line properly, and the data is displayed correctly in the system.

In PLIN view Pro, there is an option called "New frame," which allows setting the Direction to 'Publish' in slave mode to 'Write' data. I want to implement this functionality using the PLIN API while in slave mode.

So far, I have used the RegisterClient, ConnectClient, InitializeHardware, and GetAvailableHardware functions.

I initialized the hardware in slave mode using the InitializeHardware function and set up the FrameId, Length, ChecksumType = TLIN_CHECKSUMTYPE_ENHANCED, Direction = TLIN_DIRECTION_PUBLISHER, Data, and Checksum correctly.

Then, I used the Write function. There were no errors(sometiems error occurs (error number: 1(Inconsistent sync)))
, but when I check with PLIN view, it doesn't seem like the message is being written.

Am I missing something?

Thank you

Re: Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Wed 28. Aug 2024, 12:34
by M.Heidemann
Hello,

There is a PLIN-API Subforum, i will move the topic here.

Slave nodes cannot use the "Write" function:
plinapi-master.png
plinapi-master.png (78.64 KiB) Viewed 5832 times
If you want to change the data of your subscriber frame you will have to use LIN_UpdateByteArray to do so.

BR

Marvin

Re: Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Mon 24. Mar 2025, 16:56
by KiranKeshavegowda
Hello..
I am new to LIN protocol and studying how to Simulate LIN message using the LIN API.. is it possible to share the Code developed to transmit the message using LIN API.

Thanks

Re: Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Tue 25. Mar 2025, 08:39
by M.Maidhof
Hi,

please have a look in the samples directory of the PLIN API package. There you will find example code on how to use the API.

regards

Michael

Re: Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Wed 26. Mar 2025, 09:21
by KiranKeshavegowda
Hello Michael
So if we need to write script in PCAN View Pro tool then we need to refer to C# examples right not the VB Script.

Thanks

Re: Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Wed 26. Mar 2025, 09:56
by M.Maidhof
Hi,

these are two differnt kind of scripts. With the VBscript option you can perform a kind of "remote control" of the PLIN-View Pro software. With a VBscript you can start the tool, load a specific configuration, send LIN frames, start and stop tracer and so on. With a c# script you can for example build a CRC calculation and counter for publisher data when you use it as LIN master with an active scheduler.
For more complex tasks, it will be better to write an own application based on our PLIN-API. In that case you have any possibilities on how to handle the LIN data.

regards

Michael

Re: Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Wed 2. Apr 2025, 15:35
by KiranKeshavegowda
Hello Michael,
Here is what i am trying to do, i have two peak Lin H/W (IPEH-004052). i want to configure one of the unit as master and other as Slave. So when the master transmits the Message/LIN Frame , i want the Slave to Respond with a frame.. let me know if we can do this using C# script. and i have an LDF file.. i was not able to Attach so i am copying the LIN LDF file below..

thanks

Code: Select all

LIN_description_file;
LIN_protocol_version = "2.0";
LIN_language_version = "2.0";
LIN_speed = 19.2 kbps;

Nodes {
  Master: MCPx, 10 ms, 0 ms ;
  Slaves: TAPx, DIAG_TESTER ;
}

Signals {
  SetSpeedOP: 8, 255, TAPx, MCPx, DIAG_TESTER ;
  ActualSpeedOP: 8, 255, TAPx, MCPx, DIAG_TESTER ;
  VoltageOP: 8, 255, TAPx, MCPx, DIAG_TESTER ;
  TemperatureOP: 8, 255, TAPx, MCPx, DIAG_TESTER ;
  CurrentOP: 8, 255, TAPx, MCPx, DIAG_TESTER ;
  RPMMonitoringOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  StatusEmergencyModeOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  OverTemperatureOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  OverCurrentOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  DryRunOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  VoltageErrorOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  DeblockingOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  StatusEmergencyModeFunctionOP: 2, 3, TAPx, MCPx, DIAG_TESTER ;
  StatusPostRunningModeOP: 3, 3, TAPx, MCPx, DIAG_TESTER ;
  CommunicationErrorOP: 1, 0, TAPx, MCPx, DIAG_TESTER ;
  VersionOP: 8, 0, TAPx, MCPx, DIAG_TESTER ;
  SetspeedOP: 8, 255, MCPx, TAPx, DIAG_TESTER ;
  PostRunningModeOP: 3, 0, MCPx, TAPx, DIAG_TESTER ;
  AuopReqB0: 8, 0, TAPx ;
  AuopReqB1: 8, 0, TAPx ;
  AuopReqB2: 8, 0, TAPx ;
  AuopReqB3: 8, 0, TAPx ;
  AuopReqB4: 8, 0, TAPx ;
  AuopReqB5: 8, 0, TAPx ;
  AuopReqB6: 8, 0, TAPx ;
  AuopReqB7: 8, 0, TAPx ;
}

Diagnostic_signals {
  MasterReqB0: 8, 0 ;
  MasterReqB1: 8, 0 ;
  MasterReqB2: 8, 0 ;
  MasterReqB3: 8, 0 ;
  MasterReqB4: 8, 0 ;
  MasterReqB5: 8, 0 ;
  MasterReqB6: 8, 0 ;
  MasterReqB7: 8, 0 ;
  SlaveRespB0: 8, 0 ;
  SlaveRespB1: 8, 0 ;
  SlaveRespB2: 8, 0 ;
  SlaveRespB3: 8, 0 ;
  SlaveRespB4: 8, 0 ;
  SlaveRespB5: 8, 0 ;
  SlaveRespB6: 8, 0 ;
  SlaveRespB7: 8, 0 ;
}


Frames {
  STATUS_TAPx: 52, TAPx, 8 {
    SetSpeedOP, 0 ;
    ActualSpeedOP, 8 ;
    VoltageOP, 16 ;
    TemperatureOP, 24 ;
    CurrentOP, 32 ;
    RPMMonitoringOP, 42 ;
    StatusEmergencyModeOP, 44 ;
    OverTemperatureOP, 46 ;
    OverCurrentOP, 48 ;
    DryRunOP, 50 ;
    VoltageErrorOP, 52 ;
    DeblockingOP, 54 ;
    StatusEmergencyModeFunctionOP, 56 ;
    StatusPostRunningModeOP, 60 ;
    CommunicationErrorOP, 63 ;
  }
  VARIANT_TAPx: 54, TAPx, 2 {
    VersionOP, 0 ;
  }
  Control_TAPx_MS2: 53, MCPx, 2 {
    SetspeedOP, 0 ;
    PostRunningModeOP, 12 ;
  }
}



Diagnostic_frames {
  MasterReq: 0x3c {
    MasterReqB0, 0 ;
    MasterReqB1, 8 ;
    MasterReqB2, 16 ;
    MasterReqB3, 24 ;
    MasterReqB4, 32 ;
    MasterReqB5, 40 ;
    MasterReqB6, 48 ;
    MasterReqB7, 56 ;
  }
  SlaveResp: 0x3d {
    SlaveRespB0, 0 ;
    SlaveRespB1, 8 ;
    SlaveRespB2, 16 ;
    SlaveRespB3, 24 ;
    SlaveRespB4, 32 ;
    SlaveRespB5, 40 ;
    SlaveRespB6, 48 ;
    SlaveRespB7, 56 ;
  }
}

Node_attributes {
  TAPx{
    LIN_protocol = "2.0" ;
    configured_NAD = 0x5B ;
    product_id = 0x48, 0x9000, 255 ;
    response_error = CommunicationErrorOP ;
    P2_min = 10 ms ;
    ST_min = 10 ms ;
    configurable_frames {
      STATUS_TAPx = 0x10 ;
      VARIANT_TAPx = 0x11 ;
      Control_TAPx_MS2 = 0x0 ;
    }
  }
  DIAG_TESTER{
    LIN_protocol = "1.3" ;
    configured_NAD = 0x40 ;
  }
}

Schedule_tables {
 Functional {
    STATUS_TAPx delay 70 ms ;
    VARIANT_TAPx delay 30 ms ;
    Control_TAPx_MS2 delay 100 ms ;
  }
 Init {
    MasterReq delay 10 ms ;
    SlaveResp delay 10 ms ;
  }
}


Signal_encoding_types {
  SetSpeedOP_Encoding {
    physical_value, 0, 125, 1, 0, "rpm" ;
  }
  ActualSpeedOP_Encoding {
    physical_value, 0, 255, 1, 0, "rpm" ;
  }
  VoltageOP_Encoding {
    physical_value, 0, 249, 0.1, 0, "Volts" ;
  }
  TemperatureOP_Encoding {
    physical_value, 0, 255, 1, -50, " C" ;
  }
  CurrentOP_Encoding {
    physical_value, 0, 254, 0.2, 0, "A" ;
  }
  RPMMonitoringOP_Encoding {
    logical_value, 0, "rotation monitoring active" ;
    logical_value, 1, "No rotation monitoring" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  StatusEmergencyModeOP_Encoding {
    logical_value, 0, "Low(off)" ;
    logical_value, 1, "High(on)" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  OverTemperatureOP_Encoding {
    logical_value, 0, "No overtemperature" ;
    logical_value, 1, "Overtemperature" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  OverCurrentOP_Encoding {
    logical_value, 0, "No overcurrent" ;
    logical_value, 1, "Overcurrent occurred" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  DryRunOP_Encoding {
    logical_value, 0, "No dry run detected" ;
    logical_value, 1, "Dry run detected" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  VoltageErrorOP_Encoding {
    logical_value, 0, "Supply voltage in specifided range (7V > Vbat >20V)" ;
    logical_value, 1, "Supply voltage in specifided range (7V > Vbat >20V)" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  DeblockingOP_Encoding {
    logical_value, 0, "Deblocking not active" ;
    logical_value, 1, "Deblocking active" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  StatusEmergencyModeFunctionOP_Encoding {
    logical_value, 0, "Emergency mode function deactivated" ;
    logical_value, 1, "Emergency mode function activated" ;
    logical_value, 2, "Not used" ;
    logical_value, 3, "Signal invalid" ;
  }
  StatusPostRunningModeOP_Encoding {
    logical_value, 0, "No post running" ;
    logical_value, 1, "Speed tbd RPM for tbd minutes" ;
    logical_value, 2, "Speed tbd RPM for tbd minutes" ;
    logical_value, 3, "Speed tbd RPM for tbd minutes" ;
    logical_value, 4, "Speed tbd RPM for tbd minutes" ;
    logical_value, 5, "Not used" ;
    logical_value, 6, "Not used" ;
    logical_value, 7, "Signal invalid" ;
  }
  CommunicationErrorOP_Encoding {
    logical_value, 0, "No error" ;
    logical_value, 1, "Error" ;
  }
  VersionOP_Encoding {
    physical_value, 0, 255, 1, 0, "nd" ;
  }
  SetspeedOP_Encoding {
    physical_value, 0, 125, 1, 0, "rpm" ;
  }
  PostRunningModeOP_Encoding {
    logical_value, 0, "No post running" ;
    logical_value, 1, "Speed tbd RPM for tbd minutes" ;
    logical_value, 2, "Speed tbd RPM for tbd minutes" ;
    logical_value, 3, "Speed tbd RPM for tbd minutes" ;
    logical_value, 4, "Speed tbd RPM for tbd minutes" ;
    logical_value, 5, "not used" ;
    logical_value, 6, "not used" ;
    logical_value, 7, "error" ;
  }
  AuopReqB0_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
  AuopReqB1_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
  AuopReqB2_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
  AuopReqB3_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
  AuopReqB4_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
  AuopReqB5_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
  AuopReqB6_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
  AuopReqB7_Encoding {
    physical_value, 0, 255, 1, 0, "count" ;
  }
}

Signal_representation {
  ActualSpeedOP_Encoding: ActualSpeedOP ;
  AuopReqB0_Encoding: AuopReqB0 ;
  AuopReqB1_Encoding: AuopReqB1 ;
  AuopReqB2_Encoding: AuopReqB2 ;
  AuopReqB3_Encoding: AuopReqB3 ;
  AuopReqB4_Encoding: AuopReqB4 ;
  AuopReqB5_Encoding: AuopReqB5 ;
  AuopReqB6_Encoding: AuopReqB6 ;
  AuopReqB7_Encoding: AuopReqB7 ;
  CommunicationErrorOP_Encoding: CommunicationErrorOP ;
  CurrentOP_Encoding: CurrentOP ;
  DeblockingOP_Encoding: DeblockingOP ;
  DryRunOP_Encoding: DryRunOP ;
  OverCurrentOP_Encoding: OverCurrentOP ;
  OverTemperatureOP_Encoding: OverTemperatureOP ;
  PostRunningModeOP_Encoding: PostRunningModeOP ;
  RPMMonitoringOP_Encoding: RPMMonitoringOP ;
  SetSpeedOP_Encoding: SetSpeedOP ;
  SetspeedOP_Encoding: SetspeedOP ;
  StatusEmergencyModeFunctionOP_Encoding: StatusEmergencyModeFunctionOP ;
  StatusEmergencyModeOP_Encoding: StatusEmergencyModeOP ;
  StatusPostRunningModeOP_Encoding: StatusPostRunningModeOP ;
  TemperatureOP_Encoding: TemperatureOP ;
  VersionOP_Encoding: VersionOP ;
  VoltageErrorOP_Encoding: VoltageErrorOP ;
  VoltageOP_Encoding: VoltageOP ;
}

Re: Implementing 'Publish' Direction in Slave Mode Using PLIN API

Posted: Thu 3. Apr 2025, 14:47
by M.Maidhof
Hi,

as a first step please build two projecs with your ldf in PLIN-View Pro. One as a master task with active scheduler, the other as a slave task with publishe data for some frames. If you want to use a VBscript to control the slave part, please build up a VBscript where you load the slave project configuration. Here you have to setup a kind of loop where you call obj.PublishData to chang the publiher data to your needs. Please have a look on the help of PLIN-View Pro->VB Scipt support, to see how the script looks like. See also example script here:

viewtopic.php?f=45&t=7266#p18112

As written before, an own application using the PLIN-API could be the better choice for such an application.

regards

Michael