STECHOQ / etherlab-nodejs

Bind etherlab process into nodejs
GNU Lesser General Public License v2.1
1 stars 1 forks source link

SDO Configuration #11

Closed solomonould closed 1 year ago

solomonould commented 1 year ago

More a question than an issue but can you read the etherlab sdo's? For example i can issue a command via terminal ethercat upload -p 0 0x6080 0 and i get a response with the SDO value but i get undefined if i request it in the nodejs app? Any help would be much appreciated haha, the slave config works fine for reading the PDO's and i set some of the values as parameters in the slave config but is there an equivelant command to upload in the binding? Cheers love your work!

iqrok commented 1 year ago

is there an equivelant command to upload in the binding?

do you mean read command which similar to ethercat cli command? i.e. read(pos, index, subindex)

this method is kinda flawed, need a lot of improvement.

may I know your slave config json file and the lines of code where you get undefined value? perhaps I can reproduce that problem

solomonould commented 1 year ago

Here is my slave file, yea thats the command im talking about, i have set the parameters but if i want to read them during operation i just get undefined but if i use the CLI tool i get a value :) thanks for responding, this is a great project node js based industrial control is awesome haha

function readServiceObjects(slave, node = null) {
    let outputData = {};
    outputData['SyncTypeOutput'] = etherlab.read(slave, 0x1c32, 0x01 ); //sync type output
    outputData['SyncTypeInput'] = etherlab.read(slave, 0x1c33, 0x01 ); //sync type input

    if (node) {
        node.send([null, { payload: outputData }]); // Send outputData as the payload to Node-RED
    }
}
{
        "alias": 0,
        "position": 0,
        "vendor_id": "0x00000a1e",
        "product_code": "0x00000201",
        "parameters": [
            {
                "index": "0x1C13",  
                "subindex": "0x1",
                "size": 16,
                "value": "0x1A01"
            },
            {
                "index": "0x1C12",  
                "subindex": "0x1",
                "size": 16,
                "value": "0x1601"
            },
            {
                "index": "0x1C33",  
                "subindex": "0x01",
                "size": 16,
                "value": "0x0"
            },
            {
                "index": "0x1C32", 
                "subindex": "0x01",
                "size": 16,
                "value": "0x0"
            }
        ],
        "syncs": [
            {
                "index": 2,
                "watchdog_enabled": true,
                "pdos": [
                    {
                        "index": "0x1601",
                        "entries": [
                            {
                                "index": "0x6060",
                                "subindex": "0x00",
                                "size": 8,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6040",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d01",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d02",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d03",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x607a",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": true
                            },
                            {
                                "index": "0x60ff",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": true
                            },
                            {
                                "index": "0x2d20",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6071",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6081",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6083",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6084",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6087",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60e0",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60e1",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60b8",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            }
                        ]
                    }
                ]
            },
            {
                "index": 3,
                "watchdog_enabled": false,
                "pdos": [
                    {
                        "index": "0x1A01",
                        "entries": [
                            {
                                "index": "0x6061",
                                "subindex": "0x00",
                                "size": 8,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6041",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d11",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d12",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d13",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d15",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2d17",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6064",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": true
                            },
                            {
                                "index": "0x606c",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": true
                            },
                            {
                                "index": "0x60f4",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x6077",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2D68",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2D69",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x2D6A",
                                "subindex": "0x00",
                                "size": 8,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60b9",
                                "subindex": "0x00",
                                "size": 16,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60ba",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60bb",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60bc",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            },
                            {
                                "index": "0x60bd",
                                "subindex": "0x00",
                                "size": 32,
                                "add_to_domain": true,
                                "swap_endian": false,
                                "signed": false
                            }
                        ]
                    }
                ]
            }
        ]
    }
iqrok commented 1 year ago
etherlab.read(slave, 0x1c33, 0x01 )

^ this won't do anything, because read is only for domain which has been mapped before. Sorry, but the name is kinda misleading, probably I should change those methods into readDomain writeDomain in the future.

To read SDO data like in the ethercat upload, I created sdoRead() in 9db622311aae953856ef7956ac0faaabdc7443c5 at branch sdo-access.

Basically, it creates SDO request with ecrt_slave_config_create_sdo_request, then creates read request with ecrt_sdo_request_read, and then pool the request until data is returned or error is encountered.

The setup I use to test

$ ethercat slaves
0  0:0  PREOP  +  EK1100 EtherCAT-Koppler (2A E-Bus)
1  0:1  PREOP  +  EL2004 4K. Dig. Ausgang 24V, 0.5A
2  0:2  PREOP  +  EL1014 4K. Dig. Eingang 24V, 10�s
3  0:3  PREOP  +  EL4004 4Ch. Ana. Output 0-10V, 12bit

then I used this script too test the readSdo command

const __etherlab = require('..');
const { execSync } = require('child_process');

const config = __dirname + '/slaves.sample.json';
const frequency = 1000;

const etherlab = new __etherlab(config, frequency);

etherlab.start();

function readSDO(){
    const SDOs = [
            { pos: 3, index: 0x1018, sub: 0x01, type: 'uint32' }, // Vendor Id
            { pos: 3, index: 0x1018, sub: 0x02, type: 'uint32' }, // Product Code
            { pos: 3, index: 0x1c32, sub: 0x01, type: 'uint16' }, // Sync mode
            { pos: 3, index: 0x1c32, sub: 0x02, type: 'uint32' }, // Cycle time
            { pos: 3, index: 0x1c32, sub: 0x03, type: 'uint32' }, // Shift time
            { pos: 3, index: 0x1c32, sub: 0x04, type: 'uint16' }, // Sync modes supported
            { pos: 3, index: 0x8020, sub: 0x02, type: 'uint8' },  // Presentation
            { pos: 3, index: 0x7030, sub: 0x01, type: 'uint16' }, // Analog output
        ];

    const results = [];
    for(const sdo of SDOs){
        const dec = etherlab.sdoRead(sdo.pos, sdo.index, sdo.sub, sdo.type);
        const cmd = `ethercat upload -p${sdo.pos} -t${sdo.type} 0x${sdo.index.toString(16)} 0x${sdo.sub.toString(16)}`;

        let res = null;
        if(etherlab.getMasterState() == 0x08){
            try {
                res = execSync(cmd).toString()
            } catch(error) {}
        }

        results.push({ cmd, res, hex: dec?.toString(16), dec });
    }

    console.table(results);

    setTimeout(readSDO, 500); // loop SDO read operation 500ms from now
}

etherlab.on('state', current => {
    console.log('master\'s current state ', current);
});

etherlab.on('ready', async () => {

    readSDO(); // start reading SDO data

    let val = 0;
    let dir = 0;
    let bit = 0;

    // process data manipulation
    setInterval(() => {
        if(val < 0 || val > 10000){
            dir ^= 1;
        }

        if(dir){
            val += 1;
        } else {
            val -= 1;
        }

        bit ^= 1;

        etherlab.write(1, 0x7000, 0x01, bit);
        etherlab.write(1, 0x7010, 0x01, ~bit);
        etherlab.write(3, 0x7000, 0x01, val);
        etherlab.write(3, 0x7030, 0x01, val % 0xfff);
    }, 50);

    // process data reading
    setInterval(() => {
        const values = [
            etherlab.read(2, 0x6010, 0x01),
            etherlab.read(3, 0x7000, 0x01),
            etherlab.read(3, 0x7010, 0x01),
            etherlab.read(3, 0x7020, 0x01),
            etherlab.read(3, 0x7030, 0x01),
        ];

        //~ console.log(values);
    }, 100);
});

etherlab.on('error', error => {
    console.error(error);
});

The output is

$ node test-sdo.js
Using priority 99
master's current state  2
master's current state  8
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │       '0x0000 0\n'       │    '0'    │     0     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │       '0x0007 7\n'       │    '7'    │     7     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │      '0x0011 17\n'       │   '11'    │    17     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘

It yields the same result as ethercat upload

The problem is to create sdo request, the target slave must've been initialized first. Because the master, slaves, & domain initialization is triggered by the same call to start cyclic task, I have to put SDO read operations inside ready event. Otherwise, error will be thrown.

iqrok commented 1 year ago

To mitigate the problem above, the initialization process must be extracted from start process. I created branch master-init-and-activation to test this.

In short words, the initialization process can be triggered indepedently from start process. With this, I could trigger initialization process when ecat.init() is called.

What I want to achieve is to make sdoRead behaves like ethercat upload. It doesn't need the master to be in OP state.

Then I tested with this codes

const __etherlab = require('..');
const { execSync } = require('child_process');

const config = __dirname + '/slaves.sample.json';
const frequency = 1000;

const etherlab = new __etherlab(config, frequency);

function readSDO(){
    const SDOs = [
            { pos: 3, index: 0x1018, sub: 0x01, type: 'uint32' },
            { pos: 3, index: 0x1018, sub: 0x02, type: 'uint32' },
            { pos: 3, index: 0x1c32, sub: 0x01, type: 'uint16' },
            { pos: 3, index: 0x1c32, sub: 0x02, type: 'uint32' },
            { pos: 3, index: 0x1c32, sub: 0x03, type: 'uint32' },
            { pos: 3, index: 0x1c32, sub: 0x04, type: 'uint16' },
            { pos: 3, index: 0x8020, sub: 0x02, type: 'uint8' },
            { pos: 3, index: 0x7030, sub: 0x01, type: 'uint16' },
        ];

    const results = [];
    for(const sdo of SDOs){
        const dec = etherlab.sdoRead(sdo.pos, sdo.index, sdo.sub, sdo.type, 100, true);

        const cmd = `ethercat upload -p${sdo.pos} -t${sdo.type} 0x${sdo.index.toString(16)} 0x${sdo.sub.toString(16)}`;
        let res = null;
        try {
            res = execSync(cmd).toString()
        } catch(error) {}

        results.push({ cmd, res, hex: dec?.toString(16), dec });
    }

    console.table(results);

    setTimeout(readSDO, 500); // loop SDO read operation
}

etherlab.on('state', current => {
    console.log('master\'s current state ', current);
});

etherlab.on('ready', async () => {
    let val = 0, dir = 0, bit = 0;

    setInterval(() => {
        if(val < 0 || val > 10000) dir ^= 1;

        if(dir) val += 1;
        else val -= 1;

        bit ^= 1;

        etherlab.write(1, 0x7000, 0x01, bit);
        etherlab.write(1, 0x7010, 0x01, ~bit);
        etherlab.write(3, 0x7000, 0x01, val);
        etherlab.write(3, 0x7030, 0x01, val % 0xfff);
    }, 50);
});

etherlab.on('error', error => {
    console.error(error);
});

// start reading SDO data
readSDO();

// start cyclic task 10s from now
setTimeout(() => etherlab.start(), 10000);

and the output

$ node test-sdo.js
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │      '0x0073 115\n'      │   '73'    │    115    │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘

...repeated lines omitted

┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │      '0x0073 115\n'      │   '73'    │    115    │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘

Using priority 99
Timeout waiting for Busy Request!
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │ undefined │ undefined │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │       '0x0000 0\n'       │    '0'    │     0     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘
master's current state  2
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │       '0x0000 0\n'       │    '0'    │     0     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘
master's current state  8
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │       '0x0007 7\n'       │    '7'    │     7     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │      '0x0011 17\n'       │   '11'    │    17     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘
┌─────────┬───────────────────────────────────────────┬──────────────────────────┬───────────┬───────────┐
│ (index) │                    cmd                    │           res            │    hex    │    dec    │
├─────────┼───────────────────────────────────────────┼──────────────────────────┼───────────┼───────────┤
│    0    │ 'ethercat upload -p3 -tuint32 0x1018 0x1' │     '0x00000002 2\n'     │    '2'    │     2     │
│    1    │ 'ethercat upload -p3 -tuint32 0x1018 0x2' │ '0x0fa43052 262418514\n' │ 'fa43052' │ 262418514 │
│    2    │ 'ethercat upload -p3 -tuint16 0x1c32 0x1' │       '0x0001 1\n'       │    '1'    │     1     │
│    3    │ 'ethercat upload -p3 -tuint32 0x1c32 0x2' │     '0x00000000 0\n'     │    '0'    │     0     │
│    4    │ 'ethercat upload -p3 -tuint32 0x1c32 0x3' │     '0x00000000 0\n'     │    '0'    │     0     │
│    5    │ 'ethercat upload -p3 -tuint16 0x1c32 0x4' │     '0xc007 49159\n'     │  'c007'   │   49159   │
│    6    │ 'ethercat upload -p3 -tuint8 0x8020 0x2'  │        '0x00 0\n'        │    '0'    │     0     │
│    7    │ 'ethercat upload -p3 -tuint16 0x7030 0x1' │      '0x001b 27\n'       │   '1b'    │    27     │
└─────────┴───────────────────────────────────────────┴──────────────────────────┴───────────┴───────────┘

tbh, I'm not very confident with this one, because I modified a significant chunk of codes and haven't tested it thoroughly.

solomonould commented 1 year ago

man thats amazing though thank you! Yea i kinda figured out it can only read PDOs that are mapped after i opened the issue and to be fair there shouldnt really be much need to set or read pdos during OP but i was a bit confused around the read command name and figured it just did the same thing as the ethercat tool, anyway thank you ill give it a test and report back! -Sol