Пример #1
0
		self.idx = self.idx + 1

		if self.idx >= len(self.data): 
			self.idx = 0

		print "< ",  binascii.hexlify(b)	
		return b	

s = DummyStream()

ps = PacketStream(s)

try:
	ps.start()

	p = Packet()
	p.fromByteArray(array('B', [0x24, 0x07, 0x06, 0x22, 0x20, 0x4e, 0xc1]))
	print "p: " + p.__str__()

	ps.send(p)
	r = ps.receive()

	print "r: " + r.__str__()

	r = ps.xfer(p)

	print "r: " + r.__str__()

	s.slow = True

	r = ps.xfer(p)
Пример #2
0
#  License along with the JSherpa firmware; if not, write to the Free
#  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
#  02111-1307 USA.  
##

'''
This file is part of the uSherpa Python Library project
'''

from array import array
from usherpa.comm import Packet, PacketException

print "Packet Test"

# incomplete packet
p1 = Packet()
print "p1: " + p1.__str__()

# fill from bytes
pNull = array('B', [0x24, 0x04, 0x00, 0x28])

try:

	p1.fromByteArray(pNull)
	print "p1: " + p1.__str__() 

except PacketException as e:
	 print e

# from single parameters, including CRC
try: