I am porting my code to 4.3. I cannot figure out how to serialize and desalinize my variables to the Ram of the EMX. Is the register class the only option?
Yes. It is a straight read and write, nothing special.
I thought It was straight forward, but things aren’t working out, I wrote the code as follows:
GHI.Processor.Register regReader = new GHI.Processor.Register(AddressStart);
for (int i = 0, j = 0; i < length; i++, j += 4)
{
regReader.Address = (uint)(AddressStart + j * 8);
baData[i] = (byte)regReader.Value;
}
But I think the regReader.Value may be 4 bytes, but I only need 1. Right?
So how do I only grab 1 byte of data for baData from regReader.Value, i can’t figure out the syntax.
Also do I have to have a battery connected to the fez spider for the Ram to work properly?
Please clarify. I thought you are porting a working code. Did your code work on the spider before? no it does not have a battery.
The code works on and EMX in a custom box from DMC chicago. I have purchased a fex spider in the hopes to update the code base to 4.3.
The original code used BatteryRAM
BatteryRAM.Read((uint)(m_AddressStart), baData, 0, iLength);
but BatteryRam is not in 4.3, so I am trying to use GHI.Processor.Register to replace the BatteryRAM.Read\Write code
You need to get the address from the lpc2478 user manual, the battery ram address that is.
Once you have that, your code should work.
I got it its 0xE400…
Thanks for taking a look. I’ll give it another try with a single address reading 4 bytes and see if I can store and retrieve an integer to and from the RAM.
BatteryRAM Write replacement:
private static void BatteryRamWrite(uint address, ref byte[] buffer, int offset, int count)
{
int reps = 0;
for (int i = 0; i < count / 4; i++)
{
GHI.Processor.Register writer = new GHI.Processor.Register((uint)(address + offset + i*4), BitConverter.ToUInt32(buffer, i * 4));
reps++;
}
}
BatteryRAM Read replacement:
private static void BatteryRamRead(uint address, ref byte[] buffer, int offset, int count)
{
int reps = 0;
for (int i = 0; i < count / 4; i++)
{
GHI.Processor.Register reader = new GHI.Processor.Register((uint)(address + offset + i*4));
byte[] bytes = BitConverter.GetBytes(reader.Value);
buffer[4 * i] = bytes[0];
buffer[4 * i + 1] = bytes[1];
buffer[4 * i + 2] = bytes[2];
buffer[4 * i + 3] = bytes[3];
reps++;
}
}
Great. Would you please use code tags to make your code more readable?
I am not sure what you mean by code tags. Should I add comments to the code block?
Click on the button </> when you click edit please.