Skip to content

Shipment

Vending Machine Shipment and Shipment Status Query

Shipment Command

Vending Machine Shipment

Channels List, row is 10, column is 10
Layer 10123456789
Layer 210111213141516171819
Layer 320212223242526272829
Layer 430313233343536373839
Layer 540414243444546474849
Layer 650515253545556575859
Layer 760616263646566676869
Layer 870717273747576777879
Layer 980818283848586878889
Layer 1090919293949596979899

The list of channels for the physical vending machine is shown in the image.

fb4204bf8dad

kotlin
// serial driver
private lateinit var driver: UBoard

fun your_method() {
    SReplyPara(
        addr,
        no % 100,
        type,
        check,
        lift,
    ).apply {
        driver.Shipment(this)
    }.apply {
        if (!this.isOK) {
            throw Exception("shipping failed")
        }
    }
}

SReplyPara Attribute Description

AttributeTypeDefault ValueDescription
addrintSlave address.
nointChannel number, where 00 corresponds to the motor of the first channel in the first row and first column.
typeintChannel type:
1 — Spring motor
2 — Electromagnetic lock
3 — Conveyor belt channel
4 — Motor timing control
0 — Auto recognition (not recommended)
checkboolWhether to enable drop detection.
liftboolWhether to enable the elevator.

Note: The slave addr, by default is 1. If you have a vending machine is combo type, the addr may vary.

If the number of combinations is greater than 1, the address of the second machine will be 2, with a maximum support for 8 machines.

GetShipmentStatus

Query the shipment status of the driver board.

kotlin
val para = SSReplyPara(
    addr
).apply {
    driver.GetShipmentStatus(this)
}.apply {
    if (!this.isOK) {
        throw Exception("get shipment status failed")
    }
}

println("runStatus: ${para.runStatus}")
println("faultCode: ${para.faultCode}")
argumenttypedefault valuedescription
addrintSlave address.

SSReplyPara Attribute Description

AttributeTypeDefault ValueDescription
runStatusint0 - Idle
1 - Dispensing (Busy)
2 - Dispensing Complete (Success)
3 - Fault Status (Failure)
faultCodeFault code (refer to the fault code table)
0 — No error

Fault code table

Fault codes and descriptions.

CodeNameDescription
0NormalNo error
1Invalid Function CodeThe slave received a function code that cannot be executed. After issuing a query command, this code indicates no program functionality.
2Invalid Data AddressThe received data address is not allowed by the slave.
3Invalid DataThe queried value in the data area is not allowed by the slave.
4Checksum ErrorChecksum error, the master should resend the data request as per the slave's requirement.
6Slave Device BusyThe slave is busy processing a long-duration command. The master should send the request when the slave is idle.
7Slave Device FaultAn unrecoverable error occurred while the slave was executing the master's requested action.
8AcknowledgementThe slave has received the request and is processing the data, but it requires more time. To prevent a timeout error on the master, this acknowledgment response is sent. The master can then send a "query program completion" to determine if the slave has finished processing.

© All rights reserved. Dingshang Metal Products Co., Ltd.