[Tutor] Re: Serial Communication

Shantanoo Mahajan python at dhumketu.cjb.net
Thu Sep 18 13:41:20 EDT 2003


+-- Alan Trautman [python-tutor] [17-09-03 03:05 IST]:
| It's been a while since I used it but PySerial (Vaults of Parnassas and a
| personal site ) were quite easy to use.
| 
| Alan

	nice thing to use. but i have few probs.

	1) a='AB'
	let 
	b = a[0]^a[1]
	in C/C++
	how do i do this in python

	2) a='ABC'
	let
	print("%X,%X",a[0],a[1]);
	output is 41,42
	in C/C++
	again how do i get this one.

	Final aim:
	a=[a,b,c,d,e]
	a is start byte which is equal to 0x02
	b is command byte which is between 0x40 and 0x5E
	c is data byte which is between 0x30 and 0x3F
	d,e are checksum bytes are between 0x30 and 0x3F

	calculation of d,e

	chksum = a;
	chksum ^= b;
	chksum ^= c;
	d = (((chksum & 0xF0) >> 4) | 0x30)
	e = ((chksum & 0x0F) | 0x30)


	I am not able to get this thing in python.

	In what direction should I look?




| 
| -----Original Message-----
| From: Shantanoo Mahajan [mailto:python at dhumketu.cjb.net]
| Sent: Tuesday, September 16, 2003 11:29 AM
| To: tutor at python.org
| Subject: [Tutor] Serial Communication
| 
| 
| 	Hi!
| 	I would like to know whether is it
| 	possible/preferrable to go for serial communications
| 	in python. I would like to know are there any
| 	functions/approach in python parallel to interupt
| 	driven structure in C/C++.
| -- 
| Regards,
| Shantanoo Mahajan
| 
| _______________________________________________
| Tutor maillist  -  Tutor at python.org
| http://mail.python.org/mailman/listinfo/tutor
| 
| 
| 
| ------------------------------

-- 
With Best Regards,
Shantanoo Mahajan



More information about the Tutor mailing list