This function converts a kme50 log file to plain text and also looks for special conditions that can arise when converting a log file, overrun, data truncation, and change in output filename.
CanKing for Windows is a CAN bus monitor and general-purpose diagnostic tool.
Read moreThe REST API defines the set of HTTP commands and responses that a Kvaser device will understand
Read moreThis package contains our drivers and SDK for developing in a Linux environment. Everything you’ll need to get started is included in one place.
Read moreLet’s say that you are developing a CAN system. You need something to interface between CAN nodes and a computer... Read more
In this small guide we will explain how the LEDs on the U100 works and how to use them. Writer:... Read more
In this blog I will try to show how easy it is to set up a Kvaser Memorator to record…
Read moreThe CANlib SDK includes libraries, examples, support for virtual channels and TRX, an IDE for developing t programs.
The software development kit includes everything you need including virtual hardware so you can get started right away.
This package contains our drivers and SDK for developing in a Linux environment. Everything you’ll need to get started is included in one place.
The SDK includes supplementary documentation, but copies are also available for download from our Downloads page including our guide to t programming.
Is a software product from KVASER that provides support for different CAN interface boards.
Read moreThe CANLIB API consists exclusively of functions. Most of the functions return a status code of ...
Read moreCalling canInitializeLibrary() initializes the CANLIB library. It is sufficient to call this routine once.
Read moreStrictly speaking it is not necessary to clean up anything before terminating the application.
Read moreWhen the CAN controller is on bus, it is receiving messages and is sending acknowledge bits in response to all correctly received messages.
Read moreOutgoing CAN messages are buffered in a transmit queue and sent on a First-In First-Out basis.
Read moreCANLIB supports programs with multiple threads as long as one important condition is met: A handle to a CAN circuit should be used in only one thread.
Read moreThis function converts a kme50 log file to plain text and also looks for special conditions that can arise when converting a log file, overrun, data truncation, and change in output filename.
def convertEvents(kc):
# Get estimated number of remaining events in the input file. This can be
# useful for displaying progress during conversion.
total = kc.eventCount()
print("Converting about %d events..." % total)
while True:
try:
# Convert events from input file one by one until EOF is reached
kc.convertEvent()
if kc.IsOutputFilenameNew():
print("New output filename: %s" % kc.getOutputFilename())
print("About %d events left to convert..." % kc.eventCount())
except kvlc.KvlcEndOfFile:
if kc.IsOverrunActive():
print("NOTE! The extracted data contained overrun.")
kc.resetOverrunActive()
if kc.IsDataTruncated():
print("NOTE! The extracted data was truncated.")
kc.resetStatusTruncated()
break
The downloaded Python sample directory now includes wrappers for both CANIib and kvrlib. To get an idea of how to use them, see the bottom of each wrapper file. E.g. the canlib.py can be used as seen below.
import time
import kvDevice
# Define some values and messages to send to our device
# In order to hide these secret messages, we write them encoded 😉
messages = [(1, "-Jung unccraf gb n sebt'f pne jura vg oernxf qbja?"),
(2, "-Vg trgf gbnq njnl."),
(3, "-Jul jnf fvk fpnerq bs frira?"),
(4, "-Orpnhfr frira 'ngr' avar."),
(5, "-Jung vf gur qvssrerapr orgjrra fabjzra naq fabjjbzra?"),
(6, "-Fabjonyyf."),
(7, "-Jurer qvq lbh svaq gurfr?"),
(8, "-uggc://jjj.ynhtusnpgbel.pbz/wbxrf/jbeq-cynl-wbxrf")]
# We will be using the first Eagle device found connected to the PC
# For an introduction to the kvDevice object, see
# http://www.kvaser.com/developer-blog/object-oriented-approach-accessing-kvaser-device-python-3-3/
eagle_ean = "73-30130-00567-9"
dev = kvDevice.kvDevice(ean=eagle_ean)
# Open a handle to the device
dev.open()
# Load the t program into slot 0
dev.channel.scriptLoadFile(0, "envvar.txe")
# Start the program in slot 0
dev.channel.scriptStart(0)
# Our protocol states that we should wait until HostIdConnected is zero before trying to connect
print "Waiting for device to be free..."
# All calls to the kvScriptEnvarOpen() and kvScriptEnvvarGetXXX() functions are hidden in the
# envvar class inside canlib.py. Here we can access it directly with dev.channel.envvar.YYY
while dev.channel.envvar.HostIdConnected != 0:
time.sleep(0.2)
# Now we try to connect by writing our unique id into the environment variable HostIdRequest.
# We wait until our connection was accepted, i.e. HostIdConnected contains our id.
print "Requesting connection..."
myHostId = 42
print "Waiting for device to connect..."
while dev.channel.envvar.HostIdConnected != myHostId:
if dev.channel.envvar.HostIdConnected == 0:
print "Requesting connection..."
if dev.channel.envvar.HostIdRequest != myHostId:
dev.channel.envvar.HostIdRequest = myHostId
time.sleep(0.2)
print "Connected!"
# Start sending our messages to the device
for (severity, message) in messages:
print "Sending message %d" % severity
dev.channel.envvar.Severity = severity
dev.channel.envvar.Message = message.encode('rot13')
time.sleep(4)
print "Disconnect..."
dev.channel.envvar.HostIdRequest = 0
# Stop the script in slot 0
dev.channel.scriptStop(0)
Support cases are managed through the JIRA platform. Please check your Spam folder if you do not receive a JIRA email confirmation after submitting a support request.
Request more information before you complete the purchase.