1.0.11 • Published 4 years ago

ate_tbox v1.0.11

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

Describe

ATE TBox Api with nodejs

Install

npm install ate_tbox

Method description

Attribute: drivers(array)

Host driver array, driver contents include: name: device/driver name. vendor: device vendor. library: driver library path.

Method: OpenDevice(library)

This function is used to establish a connection and intialize the Pass-Thru Device and setup connect protocol channel. library: String, device library path. return: int, 0 is success.

Method: CloseDevice()

This function is used to close the connection to a Pass-Thru Device. return: int, 0 is success.

Method: SelectDrawer(index)

This function select drawer to connect. index: drawer index, range: 0 - 20, 0 is close all drawer connect.

Method: SetupDutPower(flags, limit_max, limit_min)

This function setup drawer dut power supply and protection Parameters. flags: dut power supply switch flags. limit_max: max current(mA), when the current is greater than that value, the power is off. limit_min: min current(mA), when the current is less than that value, the power is off.

Method: StartSingleTest(interval, eventCB)

This function is used to start single test. interval: drawer refresh interval(s). eventCB: event callback.

Method: StartMultiTest(interval, duration, flags, eventCB)

This function is used to start multi drawer test. interval: drawer refresh interval(s). duration: duration test time(s). flags: drawer refresh list flags. eventCB: event callback.

Method: StopMultiTest()

This function is used to stop multi drawer test.

CallBack: eventCB

Function to call when the dut information is updated or the test exits.

Usage Example

const AteApi = require('..');

function eventHandle(event) {
    if ("update" == event.event) {
        /* 更新dut信息 */
        for(var i = 0; i < event.duts.length; i++){
            console.log("<%d-%d>: sw[%d] avg[%d] min[%d] max[%d]", 
                event.index,
                i, 
                event.duts[i].sw,
                event.duts[i].avg,
                event.duts[i].min,
                event.duts[i].max);
        } 
    } else if ("exit" == event.event) {
        if (event.code == 0) {
            console.log("test done");   
        } else {
            console.log("User Request Exit");  
        }
        /* 关闭设备 */
        if (0 != AteApi.CloseDevice()) {
            console.log("device close failure.");
        } else {
            console.log("device close success.");   
        }
    } else {
        console.log("undefinition event %s.", event.event);  
    }
}

function singleTest() {
    var interval = 2;
    if (0 != AteApi.StartSingleTest(interval, eventHandle)) {
        console.log("Start Single Test failure."); 
        AteApi.CloseDevice();
        process.exit();
    } 
}

function multiTest() {
    var interval = 2;
    var duration = 30;
    var flags = 0x5;
    if (0 != AteApi.StartMultiTest(interval, duration, flags, eventHandle)) {
        console.log("Start Single Test failure."); 
        AteApi.CloseDevice();
        process.exit();
    } 
}

function doTest() {
    for(let i = 0; i < AteApi.drivers.length; i++){
        console.log("Discover Driver: ", AteApi.drivers[i].name);
    }
    /* 打开设备 */
    if (0 != AteApi.OpenDevice(AteApi.drivers[2].library)) {
        console.log("device open failure."); 
        process.exit();
    } 
    console.log("device open success."); 
    /* 选择通信抽屉 */
    if (0 != AteApi.SelectDrawer(1)) {
        console.log("Select Drawer failure."); 
        AteApi.CloseDevice();
        process.exit();
    } 
    /* 设置DUT电源 */
    if (0 != AteApi.SetupDutPower(0xFFF, 800, 200)) {
         console.log("Setup Dut Power failure."); 
         AteApi.CloseDevice();
         process.exit();
    } 
    //singleTest();
    multiTest();
}
1.0.11

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago