增加信号取反功能
This commit is contained in:
+18
-4
@@ -45,7 +45,8 @@ class Decoder(srd.Decoder):
|
||||
options = (
|
||||
# 一个数据周期10us
|
||||
{'id': 'datatime', 'desc': '数据传输时间(ns)', 'default': 10000},
|
||||
{'id': 'filename', 'desc': '解码输出文件名','default':'d:/sl2-100.csv'},
|
||||
{'id': 'filename', 'desc': '解码输出文件名','default':'d:/sl2-100.csv'},
|
||||
{'id': 'invert', 'desc': 'Invert Signal?', 'default': 'no','values': ('yes', 'no'), 'idn':'opt_invert'},
|
||||
)
|
||||
# 解析结果项定义
|
||||
# annotations里的每一项可以有2到3个属性,当有3个属性时,第一个表示类型
|
||||
@@ -245,16 +246,24 @@ class Decoder(srd.Decoder):
|
||||
self.oldsamplenum = self.samplenum
|
||||
self.highpin = 0 #当前采样宽度(78.125ns)内高电平数量
|
||||
self.lowpin = 0 #当前采样宽度(78.125ns)内低电平数量
|
||||
#当前电平值是否取反
|
||||
inv = self.options['invert'] == 'yes'
|
||||
|
||||
while True:
|
||||
if self.state2 == 'FIND START':
|
||||
#self.file.write('FIND START'+ '\n')
|
||||
self.wait({0: 'l'})
|
||||
if inv:
|
||||
self.wait({0: 'h'})
|
||||
else:
|
||||
self.wait({0: 'l'})
|
||||
self.oldsamplenum = self.samplenum
|
||||
self.state2 = 'FIND START2'
|
||||
if self.state2 == 'FIND START2':
|
||||
#self.file.write('FIND START2'+ '\n')
|
||||
self.wait({0: 'r'})
|
||||
if inv:
|
||||
self.wait({0: 'e'})
|
||||
else:
|
||||
self.wait({0: 'e'})
|
||||
start_width = self.samplenum - self.oldsamplenum
|
||||
self.oldsamplenum = self.samplenum
|
||||
if start_width >= self.bit_width*2.2:
|
||||
@@ -264,6 +273,9 @@ class Decoder(srd.Decoder):
|
||||
if self.state2 == 'FIND START3':
|
||||
#self.file.write('FIND START3'+ '\n')
|
||||
(pin,) = self.wait({0:'n'})
|
||||
if inv:
|
||||
pin =not pin
|
||||
|
||||
#当前已经累积的采样宽度
|
||||
total_width = self.samplenum - self.oldsamplenum
|
||||
if total_width>=self.bit_width : #累积采样宽度接近设置的采样次数
|
||||
@@ -272,6 +284,8 @@ class Decoder(srd.Decoder):
|
||||
if self.state2 == 'FIND DATA':
|
||||
#self.file.write('FIND DATA'+ '\n')
|
||||
(pin,) = self.wait({0:'n'})
|
||||
if inv:
|
||||
pin = not pin
|
||||
#当前已经累积的采样宽度
|
||||
total_width = self.samplenum - self.oldsamplenum
|
||||
if pin==1:
|
||||
@@ -294,4 +308,4 @@ class Decoder(srd.Decoder):
|
||||
# 底层模块提供的属性:
|
||||
# 1. self.samplenum 当前wait()调用匹配结束的采样点位置
|
||||
# 2. self.matched 本次调用wait()后所有通道的匹配结果信息,是一个uint64类型数值,
|
||||
# 表示0到63个通道的匹配信息,通过位运算来获取具体信息。
|
||||
# 表示0到63个通道的匹配信息,通过位运算来获取具体�
|
||||
Reference in New Issue
Block a user