We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
HI all iam working cygnal microcontrollers .From the console iam sending text file to the controller through uart transmission.The data in the text file is written into controller external memory. lets take an example the text file contains the below data 1111111111111111ffffffffff now i want to add 0203 to the above data that means i have to get in this format 020311111111111111110203ffffffffff0203 that means after every 8 bytes i have to add 0203 in the text file the 0203 values the user will enter as message overheads kindly provide me how to implement this regards john e
"after every 8 bytes i have to add 0203 in the text file" Well, there's the definition of the required algorithm. "kindly provide me how to implement this" Don't you have any ideas of your own?
Hint: forget about 'C' and microcontrollers for a minute; just think about how you'd do this manually. If someone gave you a list of numbers, eg, 1111111111111111ffffffffff and then said, "after every 8 digits you have to add 0203" What would you do? How would you do it?
sed -e 's/\(.\{8\}\)/0203\1/g' [file ...]
I'd assumed he wanted the Cygnal to do it...
"the text file contains the below data 1111111111111111ffffffffff now i want to add 0203 to the above data" "I'd assumed he wanted the Cygnal to do it..." Yep, that's the problem with ambiguous requirements. I had focused on file, when you had an entirely different interpretation. Either way, it shouldn't be a big deal to do.
I'd assumed he wanted the Cygnal to do it No problem. Just port Linux, bash, and sed over, then run the script.
"Just port Linux, bash, and sed over..." Or port Windows, since there are Windows-native versions of sed too!