Hardware


Shell Lab C1 is programmable CAN bus adaptor with USB interface

Characteristic:

● interactive serial console with ASCII command, online manual embedded
● programming language is not limited (Python recommended)
● quick test with Testbench App (with various demo codes)
● pip install mcush library (support windows/linux/mac) and write scripts easily

Use cases:

● auxiliary control for product development/test
● educational experiment design
● outdoor case, auto indicator
● system integration for industrial equipment

Software

Serial Communication FAQ C Programming FAQ

Serial command:

CAN bus control command
=>can --help
usage: can [-c ] [-i ] [-v ] [-e] [-r] 
options:
 -c/--cmd        info|(de)init|reset|baudrate|reset_input|read|write|filter
 -i/--idx        index param
 -v/--val        value param
 -e/--ext        extended
 -r/--rtr        remote
 data            data args
=> 

Example:

adjust baudrate (1M default)
=>can -c baudrate -v 500000
=> 
send packet (11bit identify 0xA0, 3bytes data 0x01, 0x02 and 0x03)
=>can -c write -i 0xA0 0x01 0x02 0x03
=> 
read cached packets, print line by line
=>can -c read
0B0 D 01020304
...
=> 

Python API:

Install: sudo pip3 install mcush
Upgrade: sudo pip3 install -U mcush
class ShellLabCAN(mcush.ShellLab.ShellLab):
    def can(self, cmd, index=None, value=None, ext=None, rtr=None, args=None):
        # lower level serial command
   
    def canBaudrate(self, new_baudrate):
        # set baudrate
  
    def canFilterReset(self, add_default=True):
        # reset filter
 
    def canFilterSet(self, index, enable, can_id, mask, ext=None, rtr=None):
        # set filter

    def canRead(self, lines=None, block_ms=None):
        # read cached packets

    def canReset(self):
        # reset all

    def canResetInput(self):
        # reset cache

    def canWrite(self, cob_id, dat=[], ext=None, rtr=None):
        # send packets

class ShellLabCANopen(ShellLabCAN):
    def preOperNode(self, id):

    def readFLOAT32(self, id, index, subindex):

    def readINT16(self, id, index, subindex):

    def readINT32(self, id, index, subindex):

    def readINT8(self, id, index, subindex):

    def readObject(self, id, index, subindex):

    def readUINT16(self, id, index, subindex):

    def readUINT32(self, id, index, subindex):

    def readUINT8(self, id, index, subindex):

    def resetNode(self, id):

    def startNode(self, id):

    def stopNode(self, id):

    def sync(self):
    
    def writeFLOAT32(self, id, index, subindex, val):
   
    def writeINT16(self, id, index, subindex, val):
  
    def writeINT32(self, id, index, subindex, val):
 
    def writeINT8(self, id, index, subindex, val):

    def writeNMTCommand(self, cmd, id):
    
    def writeNodeGuardRequest(self, id):
    
    def writeObject(self, id, index, subindex, val):
   
    def writeRPDO1(self, id, val):
    
    def writeRPDO2(self, id, val):
   
    def writeRPDO3(self, id, val):
  
    def writeRPDO4(self, id, val):
 
    def writeTPDO1Request(self, id):

    def writeTPDO2Request(self, id):
    
    def writeTPDO3Request(self, id):
 
    def writeTPDO4Request(self, id):
   
    def writeUINT16(self, id, index, subindex, val):
  
    def writeUINT32(self, id, index, subindex, val):
 
    def writeUINT8(self, id, index, subindex, val):

Example:

import mcush
from binascii import hexlify
s=mcush.ShellLab.ShellLabCAN('/dev/ttyACM0')  # fill the actual serial port
s.canBaudrate(500000)
s.canWrite(0xA0, [0x01, 0x02, 0x03])  # send 3bytes packet
for cid, ext, rtr, dat in s.canRead():
    dat = hexlify(dat)  # convert to HEX string
    print( 'id=0x%X, ext=%d, rtr=%d, dat=%s'% (cid, ext, rtr, dat) )

Download:

Shell Lab Testbench Application


VCP Driver(Windows)


Application