States in Ultemp.dat

Android Apps created to interface with BCS Control Systems
Post Reply
cscrum
Posts: 6
Joined: Tue Oct 05, 2010 8:52 pm
Bot?: No

States in Ultemp.dat

Post by cscrum »

So, I'm really confused about the states in this file. When I have P0 State 0 running, I get -256. In binary this is 11111111111111111111111100000000 (assuming 2's compliment). So, bits 26-31 are 11111111. How does this show state 0? P0 State 2 is -255. That is 11111111111111111111111100000001. So bits 26-31 are again 11111111. Am I missing a key ingredient here?
User avatar
ECC
Posts: 676
Joined: Fri Sep 12, 2008 12:29 pm
Bot?: No
Contact:

Re: States in Ultemp.dat

Post by ECC »

I find the best way is to convert it into hex and go from there. a little easier to visualize.

-252 = 0xFFFFFF04 (most computers sign extend this to 64 bits, but we're only looking at 32)
-1 = =0xFFFFFFFF

Process Current State breakout:
0: 4
1: 255 or 0xFF (defualt state, which means process is off)
2: 255
3: 255
4: 255
5: 255
6: 255
7: 255

heres some code that I use to check if the current state of any process has changed to determine if i need to do a full refresh. I try to keep all current info in ultemps and only read the only files when necessary:

Code: Select all

	// Test if the Current State has changed
	fullUpdate=0;
	for(i=0;i<8;i++){
		
		indx = (i<4)? ULTMP_CS0 : ULTMP_CS1;
		
		CS[i] = (ultemps[indx] >> (8*(i%4)) ) & 0xFF;
		
		if(CS[i] != oldCS[i] ){
			fullUpdate|=1;
		}
		oldCS[i] = CS[i];
	}
cscrum
Posts: 6
Joined: Tue Oct 05, 2010 8:52 pm
Bot?: No

Re: States in Ultemp.dat

Post by cscrum »

OK..now the only question I have...is that a typo with the "|" in "fullUpdate|=1;" ? I don't think I've ever seen a |= operator before.
User avatar
ECC
Posts: 676
Joined: Fri Sep 12, 2008 12:29 pm
Bot?: No
Contact:

Re: States in Ultemp.dat

Post by ECC »

Nope, |= is "Or Equal". Another way to write it would be: fullUpdate = fullUpdate | 1;

At the top of the loop, I set fullUpdate to 0, and then loop through all processes. If any of them have changed, fullUpdate is set.
Post Reply