Discussion:
[UrJTAG-dev] Patch: python binding additions
Steve Tell
2017-06-26 23:19:30 UTC
Permalink
The attached patch against git head adds to the python bindings

New chain method "flush" - calls urj_tap_chain_flush to
make sure all queued activity has been sent to the hardware cable
New chain method get_tdo - gets the current value of TDO pin.
Don't unnecessarily shift instruction registers after doing an
addpart.
Fix retrieval of data register shift-in buffer values with get_dr
Created include file py_urjtag.h so we can have more than one file
of python-C bindings
New chain method get_register - returns a python object representing a
data register (urj_data_register)
Implementation of useful methods on register objects, which can make
code dealing with multiple parts and user registers much cleaner.
Geert Stappers
2017-06-27 19:59:41 UTC
Permalink
Post by Steve Tell
The attached patch against git head adds to the python bindings
Applied and pushed to Source Forge.

Thanks for your contribution to urjtag.



Cheers
Geert Stappers


P.S.
If I didn't replied on proposed patches, I did mis them.
Just retransmit.
Benjamin Henrion
2017-06-28 05:10:12 UTC
Permalink
On Jun 27, 2017 01:29, "Steve Tell" <***@telltronics.org> wrote:


The attached patch against git head adds to the python bindings

New chain method "flush" - calls urj_tap_chain_flush to
make sure all queued activity has been sent to the hardware cable
New chain method get_tdo - gets the current value of TDO pin.
Don't unnecessarily shift instruction registers after doing an addpart.
Fix retrieval of data register shift-in buffer values with get_dr
Created include file py_urjtag.h so we can have more than one file
of python-C bindings
New chain method get_register - returns a python object representing a
data register (urj_data_register)
Implementation of useful methods on register objects, which can make
code dealing with multiple parts and user registers much cleaner.


Can you use this bindings with something like ipython?

Or do you have examples of python code?

Best,
Steve Tell
2017-06-30 03:55:41 UTC
Permalink
Post by Steve Tell
The attached patch against git head adds to the python bindings
Can you use this bindings with something like ipython?
I would imagine so.
I generally write scripts, but it would work the same interactively.
The urjtag classes are meant to be used in an object-oriented style;.
Post by Steve Tell
Or do you have examples of python code?
There's a bit of tutorial in doc/urjtag-python.txt,
and a little bit of sample code in bindings/python/t_*.py

Its hard to do demonstrate much without getting into knowledge of the
registers and instruction of the chips on your jtag chain.

A most basic usage is something like:

#!/usr/bin/python
import sys
sys.path.append( "/usr/local/lib64/python2.7/site-packages" ) # might be needed
import urjtag

chain = urjtag.chain()
chain.cable("JTAGKey") # name of your cable here
chain.tap_detect()
print chain.len()
print chain.partid(0)

# object-oriented register usage:
idreg=chain.get_register(0, "DIR", "IDCODE");
idreg.shift_ir();
idreg.shift_dr();
print idreg.get_dr_out_string(11,1) # fetch mfr-id field of register scanout value as string
print idreg.get_dr_out(11,1) # as an integer

# if it made sense to write to the id register, you could do somthing like:
idreg.set_dr_in(0xf00f, 31, 16); # change the high 16 bits
idreg.set_dr_in(1, 3, 3); # and change bit 3
idreg.shift_dr()
chain.flush() # sometimes needed to make sure urjtag flushes to the hardware



Steve

Loading...