Giter VIP home page Giter VIP logo

Comments (4)

debonte avatar debonte commented on June 8, 2024

I tried to reproduce this from your screenshot + requirements.txt, but was unsuccessful. Please provide a complete, minimal code sample (as text!) that reproduces the behavior you are seeing. The screenshot you provided above is missing imports, etc.

from pylance-release.

jmailloux avatar jmailloux commented on June 8, 2024

Here's one where it can't find database in cantools.
can_send.txt

from pylance-release.

jmailloux avatar jmailloux commented on June 8, 2024

Here is the log for that.
language_server.txt

from pylance-release.

heejaechang avatar heejaechang commented on June 8, 2024

where can one finds DbcMessage? could you provide full code including import statements and what packages needed to be installed?

that said, for your can_send.txt, some function returned Union so code requires some kind of cast/narrow/typeguard to specify which type code assumes.

import can
import time
import cantools
import cantools.database
from cantools.database.can.database import Database
from cantools.database.can.message import Message

bus = None

def send_message(msg: Message):
    signal_values = {}
    signal_db = {}
    for signal in msg.signals:
        signal_values[signal.name] = signal.minimum
        signal_db[signal.name] = {'minimum':signal.minimum, 'maximum':signal.maximum}

    while True:
        data = msg.encode(signal_values)
        message = can.Message(arbitration_id=msg.frame_id, data=data, is_extended_id=True)
        
        assert(bus is not None)
        bus.send(message)

        for key in signal_values:
            signal_values[key] += 1
            if signal_values[key] > signal_db[key]['maximum']:
                signal_values[key] = signal_db[key]['minimum']

        time.sleep(1)  # Send a message every second

if __name__ == '__main__':
    bus = can.Bus(interface='udp_multicast', channel='239.0.0.1', port=10000, receive_own_messages=False)
    db = cantools.database.load_file('../envgo/dbc/xerotech_battery_j1939.dbc')

    assert(isinstance(db, Database))

    for msg in db.messages:
        if 'VCU' not in msg.senders:
            send_message(msg)
            break

from pylance-release.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.