Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SimpleDMA eeprom mbed-rtos mbed FreescaleIAP
Fork of CDMS_CODE by
Revision 92:bce22b38c440, committed 2016-01-23
- Comitter:
- ee12b079
- Date:
- Sat Jan 23 12:59:06 2016 +0000
- Parent:
- 91:05cf9d71a665
- Child:
- 93:4d76de54a699
- Commit message:
- obsrs integrated with mcs data checked multiple segments also checked
Changed in this revision
| OBSRS.h | Show annotated file Show diff for this revision Revisions of this file |
| cdms_sd.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/OBSRS.h Sat Jan 23 12:20:56 2016 +0000
+++ b/OBSRS.h Sat Jan 23 12:59:06 2016 +0000
@@ -46,7 +46,7 @@
uint8_t SID ;
unsigned char buffer_112[112];
-uint8_t FSC;
+uint32_t FSC;
uint16_t read_success = false;
uint16_t counter_buffer_112=0, counter_EoS=0,T_frames_sent=0;
uint16_t counter_call_sign_buffer=0;
@@ -236,7 +236,7 @@
}\
else{\
valid_SID=false;\
- gPC.printf("invalid SID");\
+ /*gPC.printf("invalid SID");*/\
enable_ackandcallsign = true;\
create_Ack_andcallsign = true;\
ack_code = 0x02;\
@@ -333,7 +333,7 @@
if(segments_sent + 1>= max_segments){
adf_limit = true;
segments_sent = 0;
- gPC.printf("adf limit reached here");
+// gPC.printf("adf limit reached here");
}
else{
enable_new_segment = true;
@@ -362,11 +362,11 @@
adf_limit = true;
segments_sent++;
// gPC.printf("segments_sent = "<<segments_sent<<ENDL;
- gPC.printf("in for adf limit reached");
+// gPC.printf("in for adf limit reached");
}
else{
enable_new_segment = true;
- gPC.printf("data in next segment");
+// gPC.printf("data in next segment");
segments_sent++;
// cout<<"segments_sent = "<<segments_sent<<ENDL;
}
@@ -490,7 +490,7 @@
}
void execute_OBSRS_TC(Base_tc *tcp){
- short_TC = true;
+// short_TC = true;
//pc.printf("WELCOME\n\r");
FCTN_CDMS_SD_INIT();/* sd card initialization*/
// SID = 0x0;
@@ -499,34 +499,36 @@
// short_TC = true;
// adf_SND_SDCard();
-// if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){
-// short_TC = true;
-// }
-// else{
-// short_TC = false;
-// }
-// /* reading SID from TC */
-// SID = (tcp->TC_string[2]) & 0x0f;
-// /* reading FSC and no. of frames from TC */
-// if(short_TC){
-// FSC = tcp->TC_string[3] << 24;
-// FSC += tcp->TC_string[4] << 16;
-// FSC += tcp->TC_string[5] << 8;
-// FSC += tcp->TC_string[6];
-// no_of_frames = tcp->TC_string[7] << 8;
-// no_of_frames += tcp->TC_string[8];
-// }
-// else{
-// no_of_frames = tcp->TC_string[3];
-// for(int i=0 ;i<no_of_frames ; i++){
-// list_of_FSC[i] = tcp->TC_string[4+i];
-// }
-// }
-// gPC.printf("sid = %u \r\n",SID);
-// gPC.printf("FSC = %u\r\n",FSC);
- SID = 0x0;
- FSC = 10;
- no_of_frames = 2;
+ if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){
+ short_TC = true;
+ gPC.printf("it is short TC\r\n");
+ }
+ else{
+ gPC.printf("it is long TC\r\n");
+ short_TC = false;
+ }
+ /* reading SID from TC */
+ SID = (tcp->TC_string[2]) & 0x0f;
+ /* reading FSC and no. of frames from TC */
+ if(short_TC){
+ FSC = tcp->TC_string[3] << 24;
+ FSC += tcp->TC_string[4] << 16;
+ FSC += tcp->TC_string[5] << 8;
+ FSC += tcp->TC_string[6];
+ no_of_frames = tcp->TC_string[7] << 8;
+ no_of_frames += tcp->TC_string[8];
+ }
+ else{
+ no_of_frames = tcp->TC_string[3];
+ for(int i=0 ;i<no_of_frames ; i++){
+ list_of_FSC[i] = tcp->TC_string[4+i];
+ }
+ }
+ gPC.printf("sid = %u \r\n",SID);
+ gPC.printf("FSC = %u\r\n",FSC);
+// SID = 0x0;
+// FSC = 10;
+// no_of_frames = 2;
// cout<<"max_segments = "<<max_segments<<ENDL;
//while(0){
// while(!stop){
--- a/cdms_sd.h Sat Jan 23 12:20:56 2016 +0000
+++ b/cdms_sd.h Sat Jan 23 12:59:06 2016 +0000
@@ -38,7 +38,7 @@
//void FCTN_CDMS_INIT_SD();
//int FCTN_CDMS_WR_SD(const uint8_t *, uint64_t);
//int FCTN_CDMS_RD_SD(uint8_t *, uint64_t);
-uint8_t FCTN_SD_MNGR(uint8_t);
+uint32_t FCTN_SD_MNGR(uint8_t);
int cmd(int, int);
@@ -48,9 +48,9 @@
int read(uint8_t*, uint32_t );
int write(const uint8_t*, uint32_t );
static uint32_t ext_bits(unsigned char *, int , int );
-int SD_WRITE(uint8_t*,uint8_t,uint8_t);
+int SD_WRITE(uint8_t*,uint32_t,uint8_t);
void FCTN_CDMS_SD_INIT();
-int SD_READ(uint8_t*,uint8_t,uint8_t);
+int SD_READ(uint8_t*,uint32_t,uint8_t);
#define SDCARD_FAIL 0
#define SDCARD_V1 1
#define SDCARD_V2 2
@@ -81,54 +81,68 @@
-uint8_t FCTN_SD_MNGR(uint8_t sid)
+uint32_t FCTN_SD_MNGR(uint8_t sid)
{
-
+
uint32_t SD_MNG_SECT=7000;
- uint32_t block_number;
- uint8_t fsc;
- uint8_t *buffer;
- uint32_t i=0;
- disk_read(buffer, SD_MNG_SECT);
-
+
+ uint32_t fsc;
+ uint8_t buffer[512];
+ int b=disk_read(buffer, SD_MNG_SECT);
if(sid==0x0)
{
- fsc=buffer[0];
- buffer[0]++;
+
+ fsc=(uint32_t)(buffer[0]<<24)+(uint32_t)(buffer[1]<<16)+(uint32_t)(buffer[2]<<8)+(uint32_t)buffer[3];
+ uint32_t next_fsc=fsc+1;
+ buffer[0]=(uint8_t) (next_fsc>>24 & 0xFF);
+ buffer[1]=(uint8_t) (next_fsc>>16 & 0xFF);
+ buffer[2]=(uint8_t) (next_fsc>>8 & 0xFF);
+ buffer[3]=(uint8_t) (next_fsc & 0xFF);
buffer[511]+=2;
disk_write(buffer,SD_MNG_SECT);
}
if(sid==0x1)
{
- fsc=buffer[1];
- buffer[1]++;
+ fsc=(uint32_t)(buffer[4]<<24)+(uint32_t)(buffer[5]<<16)+(uint32_t)(buffer[6]<<8)+(uint32_t)buffer[7];
+ uint32_t next_fsc=fsc+1;
+ buffer[4]=(uint8_t) (next_fsc>>24 & 0xFF);
+ buffer[5]=(uint8_t) (next_fsc>>16 & 0xFF);
+ buffer[6]=(uint8_t) (next_fsc>>8 & 0xFF);
+ buffer[7]=(uint8_t) (next_fsc & 0xFF);
buffer[511]+=2;
disk_write(buffer,SD_MNG_SECT);
}
if(sid==0x2)
{
- fsc=buffer[2];
- buffer[2]++;
+ fsc=(uint32_t)(buffer[8]<<24)+(uint32_t)(buffer[9]<<16)+(uint32_t)(buffer[10]<<8)+(uint32_t)buffer[11];
+ uint32_t next_fsc=fsc+1;
+ buffer[8]=(uint8_t) (next_fsc>>24 & 0xFF);
+ buffer[9]=(uint8_t) (next_fsc>>16 & 0xFF);
+ buffer[10]=(uint8_t) (next_fsc>>8 & 0xFF);
+ buffer[11]=(uint8_t) (next_fsc & 0xFF);
buffer[511]+=2;
disk_write(buffer,SD_MNG_SECT);
}
if(sid==0x3)
{
- fsc=buffer[30];
- printf("Hey buffer[300] pre-increment is %d\r\n",buffer[300]);
- buffer[300]+=1;
- printf("Hey buffer[300] post-increment is %d\r\n",buffer[300]);
+ fsc=(uint32_t)(buffer[12]<<24)+(uint32_t)(buffer[13]<<16)+(uint32_t)(buffer[14]<<8)+(uint32_t)buffer[15];
+ uint32_t next_fsc=fsc+1;
+ buffer[12]=(uint8_t) (next_fsc>>24 & 0xFF);
+ buffer[13]=(uint8_t) (next_fsc>>16 & 0xFF);
+ buffer[14]=(uint8_t) (next_fsc>>8 & 0xFF);
+ buffer[15]=(uint8_t) (next_fsc & 0xFF);
buffer[511]+=2;
disk_write(buffer,SD_MNG_SECT);
- disk_read(buffer, SD_MNG_SECT);
- printf("Hey buffer[300] post writing is %d\r\n",buffer[300]);
- printf("Hey buffer[511] post writing is %d\r\n",buffer[511]);
}
if(sid==0x4)
{
- fsc=buffer[4];
- buffer[4]++;
+ fsc=(uint32_t)(buffer[16]<<24)+(uint32_t)(buffer[17]<<16)+(uint32_t)(buffer[18]<<8)+(uint32_t)buffer[19];
+ uint32_t next_fsc=fsc+1;
+ buffer[16]=(uint8_t) (next_fsc>>24 & 0xFF);
+ buffer[17]=(uint8_t) (next_fsc>>16 & 0xFF);
+ buffer[18]=(uint8_t) (next_fsc>>8 & 0xFF);
+ buffer[19]=(uint8_t) (next_fsc & 0xFF);
buffer[511]+=2;
disk_write(buffer,SD_MNG_SECT);
}
@@ -136,7 +150,7 @@
}
-int SD_WRITE(uint8_t* buffer,uint8_t fsc,uint8_t sid)
+int SD_WRITE(uint8_t* buffer,uint32_t fsc,uint8_t sid)
{
uint32_t SD_SCP_FIRST=1001;
@@ -154,7 +168,7 @@
int result;
if(sid==0x0)
{
- block_number=SD_SCP_FIRST+uint32_t(fsc);
+ block_number=SD_SCP_FIRST+fsc;
// printf("write_block_number=%d\r\n",block_number);
result= disk_write(buffer,block_number);
return result;
@@ -187,7 +201,7 @@
return 1;
}
-int SD_READ(uint8_t* buffer,uint8_t fsc,uint8_t sid)
+int SD_READ(uint8_t* buffer,uint32_t fsc,uint8_t sid)
{
uint32_t SD_SCP_FIRST=1001;
@@ -205,7 +219,7 @@
int result;
if(sid==0x0)
{
- block_number=SD_SCP_FIRST + uint32_t(fsc);
+ block_number=SD_SCP_FIRST + fsc;
// sd1.printf("read_block_number=%d\r\n",block_number);
result= disk_read(buffer,block_number);
}
@@ -595,4 +609,4 @@
}
return 0; //normal return
-}
+}
\ No newline at end of file
