Beginner needs help with project
so purchased arduino uno rev3 radioshack $35. (later seen online <20) in hopes of transferring functions on use xbox repair services. have believe coding needed, have no idea how to implement r3 board. code below c# , pc based. have hex file used in board once preformed function me. used xloader try , load once after 20 mins exited. possible use code on board? sure needs altering tho.
code: [select]
using system;
using system.io;
using x360utils.nand;
public class basicnandreader: idisposable {
public basicnandreader(string file): this(file.openread(file)) { }
public basicnandreader(stream input)
{
basestream = input;
checkmagic();
checkformeta();
}
public bool hasspare { get; internal set; }
public long length {
{
if(!hasspare)
return basestream.length;
return (basestream.length / 0x210) * 0x200;
}
}
public long position {
{
if(!hasspare)
return basestream.position;
return (basestream.position / 0x210) * 0x200 + basestream.position % 0x210;
}
set { setposition(value); }
}
public stream basestream { get; private set; }
public void dispose() { basestream.dispose(); }
internal virtual void setposition(long offset) { seek(offset, seekorigin.begin); }
internal void checkmagic() {
basestream.seek(0, seekorigin.begin);
var buf = new byte[2];
basestream.read(buf, 0, 2);
if(buf[0] != 0xff || buf[1] != 0x4f)
throw new nandreaderexception(nandreaderexception.errortypes.badmagic, string.format("expected: 0xff4f got: 0x{0:x2}{1:x2}", buf[0], buf[1]));
}
internal void checkformeta() {
basestream.seek(0, seekorigin.begin);
var buf = new byte[0x630]; // 3 page buffer
if(basestream.read(buf, 0, buf.length) != buf.length)
throw new nandreaderexception(nandreaderexception.errortypes.notenoughdata);
hasspare = true; // let's assume has spare before begin...
for(var = 0; < buf.length; += 0x210) {
if(!meta.checkpageecd(ref buf, i))
hasspare = false; // don't have spare...
}
}
public void close() { basestream.close(); }
public virtual int read(byte[] buffer, int offset, int count) {
if(!hasspare)
return basestream.read(buffer, offset, count);
var read = 0;
if(basestream.position % 0x210 > 0) {
int pageoffset = (int)(0x200 - basestream.position % 0x210);
var size = program.getsmallest(pageoffset, count);
read = basestream.read(buffer, offset, size);
offset += size;
if(size == pageoffset)
basestream.seek(0x10, seekorigin.current);
}
while(read < count) {
var size = program.getsmallest(0x200, count - read);
read += basestream.read(buffer, offset, size);
offset += size;
if(size == 0x200)
basestream.seek(0x10, seekorigin.current);
}
return read;
}
public byte readbyte() {
var buf = new byte[1];
if(read(buf, 0, 1) == 1)
return buf[0];
throw new nandreaderexception(nandreaderexception.errortypes.notenoughdata);
}
public byte[] readbytes(int count) {
var buf = new byte[count];
if(read(buf, 0, count) == count)
return buf;
throw new nandreaderexception(nandreaderexception.errortypes.notenoughdata);
}
public void seek(long offset, seekorigin origin) {
if(hasspare)
offset = ((offset / 0x200) * 0x210) + offset % 0x210;
basestream.seek(offset, origin);
}
}
}
that looks java. arduino uno or mega cannot run that.
you can rewrite code in c++. seems read file on
searching special code?
you can rewrite code in c++. seems read file on


Arduino Forum > Using Arduino > Microcontrollers > Beginner needs help with project
arduino
Comments
Post a Comment