Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hallo zusammen,

ich versuche momentan, Daten über das CAN-Bricklet V2 zu senden. Grundlegend funktioniert das auch gut, allerdings komme ich bei Nutzung der API immer wieder in eine Leistungsgrenze, die bei circa 120 Frames/Sekunde liegt.

Folgendes Setup verwende ich dabei:

  • ESP32 Brick
  • 2x CAN Bricklet V2 (einer sendet, einer liest)
  • Nutzung der JavaScript oder Python API unter Verwendung eines modifizierten Beispiels (Code weiter unten)

Falls ich etwas übersehen habe, bin ich über jede Hilfe dankbar. 

Viele Grüße

 

var Tinkerforge = require('tinkerforge');

var HOST = '10.0.0.1';
var PORT = 4223;
var UID = 'XXXX'; // Change XYZ to the UID of your CAN Bricklet 2.0

var ipcon = new Tinkerforge.IPConnection(); // Create IP connection
var can = new Tinkerforge.BrickletCANV2(UID, ipcon); // Create device object


  
function sleep(ms) {
    return new Promise((resolve) => {
      setTimeout(resolve, ms);
    });
}

ipcon.connect(HOST, PORT,
    function (error) {
        console.log('Error: ' + error);
    }

); // Connect to brickd
// Don't use device before ipcon is connected

ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
    async function (connectReason) {
        // Configure transceiver for loopback mode
        can.setTransceiverConfiguration(125000, 625,
                                        0);

        // Enable frame read callback
        can.setFrameReadCallbackConfiguration(false);

        let counter = 0;
        // Write standard data frame with identifier 1742 and 3 bytes of data
        while (true) {
        
        can.writeFrame(Tinkerforge.BrickletCANV2.FRAME_TYPE_STANDARD_DATA, 1, [counter, 23, 17]);
        console.log(counter);
        counter++;
        await sleep(1)
        if (counter == 255)
            counter = 0
        
        }
    }
);

// Register frame read callback
can.on(Tinkerforge.BrickletCANV2.CALLBACK_FRAME_READ,
    // Callback function for frame read callback
    function (frameType, identifier, data) {
        if(frameType === Tinkerforge.BrickletCANV2.FRAME_TYPE_STANDARD_DATA) {
            console.log('Frame Type: Standard Data');
        }
        else if(frameType === Tinkerforge.BrickletCANV2.FRAME_TYPE_STANDARD_REMOTE) {
            console.log('Frame Type: Standard Remote');
        }
        else if(frameType === Tinkerforge.BrickletCANV2.FRAME_TYPE_EXTENDED_DATA) {
            console.log('Frame Type: Extended Data');
        }
        else if(frameType === Tinkerforge.BrickletCANV2.FRAME_TYPE_EXTENDED_REMOTE) {
            console.log('Frame Type: Extended Remote');
        }

        console.log('Identifier: ' + identifier);

        var str = 'Data (Length: ' + data.length  + '):';

        for (var i = 0; i < data.length  && i < 8; ++i) {
            str += ' ' + data[i];
        }

        console.log(str);
        console.log();
    }
);

console.log('Press key to exit');
process.stdin.on('data',
    function (data) {
        can.setFrameReadCallbackConfiguration(false);

        ipcon.disconnect();
        process.exit(0);
    }
);

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.