python - Faster alternatives to Popen for CAN bus access? -


i'm using popen send instructions utility (canutils... cansend function in particular) via command line.

the entire function looks this.

def _cansend(self, register, value, readwrite = 'write'):     """send can frame"""     queue=self.canbus.queue     cobid = hex(0x600 + self.nodeid)     #assign nodeid     indexbytelow,indexbytehigh,indexbytehigher,indexbytehighest = _bytes(register['index'], register['objectdatatype'])     subindex = hex(register['subindex'])     valuebytelow,valuebytehigh,valuebytehigher,valuebytehighest = _bytes(value, register['objectdatatype'])     io = hex(command_specifier[readwrite])     frame = ["cansend", self.formattedcanbus, "-i", cobid, io, indexbytelow, indexbytehigh, subindex, valuebytelow, valuebytehigh, valuebytehigher, valuebytehighest, "0x00"]     popen(frame,stdout=pipe)     a=queue.get()     queue.task_done()     return 

i running issues trying send frames (the popen frame executes command sends frame) in rapid succession, found popen line taking somewhere on order of 35 ms execute... every other line less 2 us.

so... might better way invoke cansend function (which, again, part of canutils utility..._cansend python function above calls ) more rapidly?

i suspect of time due overhead of forking every time run cansend. rid of it, you'll want approach doesn't have create new process each send.

according this blog post, socketcan supported python 3.3. should let program create , use can sockets directly. that's direction you'll want go.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -