Hi again,
Here is my problem
I'm writing a program in C# ,in order to program te flash memory of a PIC 18F458.It will get a pre-compiled hex file(IntelHex 32 file format) and upload it to PIC18F458 by using PC's parallel port.
An intel hex file looks like following
":AABBBBCCDDHHH....HHFF"
AA:#of data bytes
BBBB:address of data in destination
CC:Record Type,depending on this ,address of data changes
HH....HH: Data,which is in hex format and contains AA*2 characters
FF:Check Sum
//I can read the contents of file by OpenFileDialog and pass it in a string by read line method.//
System.IO.streamreader sr=new System.IO.stream reader(openfiledialog.filename);
//then pass it in to a string
line=sr.readline();
// and in a while loop
while(line!=NULL){
string data_count=line.substring(1,2);
string address=line.substring(3,4);
string record_type=line.substring(7,2);
string data=line.substring(9,number);// pre calculated
string checksum=line.substring(9+number,2);
}
I have 2 questions
1- how to send a data over parallel port in C#?I'll only send data no need to read.
2-How can I convert the contents of string variables into binary?Is there a class or a function for this? or should i write it down by myself by using mod 2 and shift right method?
Thanks ,i'm sorry for this long message
Here is my problem
I'm writing a program in C# ,in order to program te flash memory of a PIC 18F458.It will get a pre-compiled hex file(IntelHex 32 file format) and upload it to PIC18F458 by using PC's parallel port.
An intel hex file looks like following
":AABBBBCCDDHHH....HHFF"
AA:#of data bytes
BBBB:address of data in destination
CC:Record Type,depending on this ,address of data changes
HH....HH: Data,which is in hex format and contains AA*2 characters
FF:Check Sum
//I can read the contents of file by OpenFileDialog and pass it in a string by read line method.//
System.IO.streamreader sr=new System.IO.stream reader(openfiledialog.filename);
//then pass it in to a string
line=sr.readline();
// and in a while loop
while(line!=NULL){
string data_count=line.substring(1,2);
string address=line.substring(3,4);
string record_type=line.substring(7,2);
string data=line.substring(9,number);// pre calculated
string checksum=line.substring(9+number,2);
}
I have 2 questions
1- how to send a data over parallel port in C#?I'll only send data no need to read.
2-How can I convert the contents of string variables into binary?Is there a class or a function for this? or should i write it down by myself by using mod 2 and shift right method?
Thanks ,i'm sorry for this long message