How to pass values larger than a byte from GCV to GPC?

GCV scripting for Gtuner IV and Titan Two. Configuration, examples, questions.

How to pass values larger than a byte from GCV to GPC?

Postby GarrisonXV » Sun Nov 29, 2020 12:54 am

I am currently passing two values from my GCV script to my GPC script. I was easily setting them for example like:
self.gcvdata[0] = 1
self.gcvdata[1] = 100
which worked fine but now I need the second value at index 1 to be anywhere from 500 to 5000 (a byte maxes out at 255). I do not have much experience with byte arrays so can someone help me with passing the larger value? Thanks!
User avatar
GarrisonXV
Sergeant
Sergeant
 
Posts: 9
Joined: Wed Nov 11, 2020 1:03 am

Re: How to pass values larger than a byte from GCV to GPC?

Postby J2Kbr » Mon Nov 30, 2020 9:30 am

Example of passing int16 value.

On Phyton script:
Code: Select all
gcvdata = bytearray()
gcvdata.extend(int(value).to_bytes(2, byteorder='big', signed=True))

On Titan Two script:
Code: Select all
int16 value;
gcv_read(0, &value);


And for fix32 value.

On Phyton script:
Code: Select all
gcvdata = bytearray()
gcvdata.extend(int(value*0x10000).to_bytes(4, byteorder='big', signed=True))

On Titan Two script:
Code: Select all
fix32 value;
gcv_read(0, &value);
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm


Return to Gtuner Computer Vision

Who is online

Users browsing this forum: No registered users and 140 guests