Click or drag to resize

LoconetServiceTxPacket Method

Transmits a packet asynchronously with normal priority.

Namespace:  RRAutoLib.Loconet
Assembly:  RRAutoLib (in RRAutoLib.dll) Version: 4.0.8678.28884
Syntax
Public Function TxPacket ( 
	objPacket As Packet,
	Optional sctCancelToken As CancellationToken = Nothing
) As Task(Of Boolean)

Parameters

objPacket
Type: RRAutoLib.LoconetPacket
The Packet to be transmited.
sctCancelToken (Optional)
Type: System.ThreadingCancellationToken
Token provided by a controlling source to notify this method that it should cancel its execution.

Return Value

Type: TaskBoolean
The awaitable Task returning True if the packet echoed back from the Loconet interface, indicating a successfull send. False could be returned if the service is stopped or the interface did not respond in a timely fashion.
Remarks
The Loconet service has two transmition queues; a normal queue accessed by TxPacket and a priority queue accessed by TxPriorityPacket(Packet, CancellationToken). Packets placed in the priority queue will jump in line to be transmited ahead of packets placed in the normal queue. For example, TxPriorityPacket(Packet, CancellationToken) is better suited for locomotive control where responsiveness is more important. Response packets are returned through the sending packet's RxPacket property for those that expect them.
Examples
The following example request data from command station slot 3. Data can then be read from the returned objResponsePacket.
VB
'assumes LoconetService (locServ) has been previously initialized and started
Dim packet As New PkReqSlotData(3)
Dim success As Boolean = Await locServ.TxPacket(packet)
Dim responsePk As Packet = packet.RxPacket
See Also