DreamSourceLab / DSView

An open source multi-function instrument for everyone
www.dreamsourcelab.com
GNU General Public License v3.0
1.13k stars 417 forks source link

encode question:Can user add user-define decode rule to encode signal? #202

Open EdiqC opened 5 years ago

EdiqC commented 5 years ago

is that user can add user-define decode rule to encode signal? such like define channel 0 ,1,2,3 means 0000:idle 0001:read 0010:write etc

DreamSourceLab commented 5 years ago

Yes. Add your own decoder (written in python) to $DSView$/decoders path.

EdiqC commented 5 years ago

i do follow your path and find some sample code there pd.py is base on libsigrokdecode protocol decoders

how can i decode 4 channel signal , which means state machine to me: [channel0,channel1,channel2,channel3]=[0,0,0,0] decode 0 if means fifo empty [channel0,channel1,channel2,channel3]=[1,0,0,0] decode 1 if means fifo half full [channel0,channel1,channel2,channel3]=[0,1,0,0] decode 2 if means fifo full etc.

what is annotation_rows and binary for? if so how i have to set annotation_rows and binary ? so many thanks

below are my code class Decoder(srd.Decoder): api_version = 2 id = '0:stateMachine' name = '0:stateMachine' longname = 'stateMachine for myIP' desc = 'Two-wire, multi-master, serial bus.' license = 'gplv2+' inputs = ['logic'] outputs = ['stateMachine'] channels = ( {'id': 'gipo0', 'name': 'GPIO0', 'desc': 'GPIO0 line'}, ) options = ( {'id': 'gipo1', 'name': 'GPIO1', 'desc': 'GPIO1 line'}, {'id': 'gipo2', 'name': 'GPIO2', 'desc': 'GPIO2 line'}, {'id': 'gipo3', 'name': 'GPIO3', 'desc': 'GPIO3 line'}, ) annotations = ( ('2', 'fifoFull', 'fifofFull'), ('1', 'fifoHalf', 'fifoHalfFull'), ('0', 'fifoEty', 'fifoEmpty'), ) annotation_rows = ( ) binary = ( )