bladox.com Forum Index bladox.com
Turbo SIM Toolkit Adapter Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with uploading programs using cemu

 
Post new topic   Reply to topic    bladox.com Forum Index -> Development
View previous topic :: View next topic  
Author Message
bugra.hasbek



Joined: 14 Jul 2009
Posts: 26

PostPosted: Thu Oct 08, 2009 3:14 pm    Post subject: Problem with uploading programs using cemu Reply with quote

Hi

Background information: I am writing a program which checks a certain variable from time to time and do something when the variable has a certain value. Here is the skeleton of my app

Code:
u8 flag;
void back_func(void *)
{
         while(1)
         {
                if(flag == 0x01)
                         /// do something
                 delayMs(100);
        }
}

void turbo_handler (u8 action, void *data)
{
   switch (action)
   {
      case ACTION_APP_INIT:
         /// some init code here
         flag = 0x00;
         /// run the program in a seperate thread so that it wont block main thread
         stk_thread(back_func, NULL);
         break;         
      /// some more code here, which handles other cases
      default:
         break;
   }
}


The problem is my code compiles succesfully but i cant upload it to tl 2 using cemu. It gets stuck at a certain part

root ImsiChanger>cemu --app imsi_changer.trb
SIM mode initialized, sim.trb
SIM_ATR: 3B 3E 94 00 80 31 E0 73 FE 21 13 62 00 34 83 81

Uploaded 128/834 bytes
Uploaded 256/834 bytes
Uploaded 384/834 bytes
Uploaded 512/834 bytes
Uploaded 640/834 bytes
Uploaded 768/834 bytes
Uploaded 834/834 bytes
^C
hangs at this point so i had to press ctrl+c. Program uploads succesfully if i delete 'while-delayMs' part, which implies that 'while-delayMs' part somehow blocks upload process. Why would such a thing happen? After all, i am only uploading the program, not run it...

i analyzed cemu source code and find where upload gets stuck. app_close function calls ch_write function which gets stuck in the below line
Code:
 
  ret = sim (ME_CMD_UPDATE_RECORD, 0x01, 0x04, 0xB0, buf);


i checked etsi 11.11 for 'Update Record' but it was rather unhelpfull.
Quote:
8.6 UPDATE RECORD
This function updates one complete record in the current linear fixed or cyclic EF. This function shall only
be performed if the UPDATE access condition for this EF is satisfied. The UPDATE can be considered as
a replacement of the relevant record data of the EF by the record data given in the command. The record
pointer shall not be changed by an unsuccessful UPDATE RECORD function.

It basicaly states that a record in the sim will be overwritten with the provided data. If data is only overwritten, why would a single line of code blocks upload of the program?

I would appreciate if you can show a way to upload the program as it is, or show another way for running a function in the background.
Back to top
View user's profile Send private message
pz
Guest





PostPosted: Sun Oct 11, 2009 1:04 pm    Post subject: Reply with quote

You cannot do the while(1)delay() loop - you block whole processing. This is not parallel/multi thread environment, i.e. that more thread/processes would be running in parallel. The stk_thread() is about spawning STK thread, which is more processing thread for STK commands and is being called when there is something STK related. GSM loop is running otherwise and this one gets blocked by the while(1)loop().

So try to do following:

Code:

u8 flag;
void back_func(void *)
{
         while(1)
         {
                if(flag == 0x01)
                         /// do something
                 more_time()
        }
}

void turbo_handler (u8 action, void *data)
{
   switch (action)
   {
      case ACTION_FIRST_STK:
         /// some init code here
         flag = 0x00;
         /// run the program in a seperate thread so that it wont block main thread
         stk_thread(back_func, NULL);
         break;         
      /// some more code here, which handles other cases
      default:
         break;
   }
}


more_time() is STK function. It's not guaranteed that it will be 10x per sec,
it can be faster/slower depending on phone and what the phone is doing. I.e. it's not real time - not guaranteed response in time. I also wonder how this will influence other STK functionality, e.g. entering menu. It should work but will be probably slower.

If you needed anything real time then TM2 is your friend - again. This one has second mcu that is running all the time.[/code]
Back to top
bugra.hasbek



Joined: 14 Jul 2009
Posts: 26

PostPosted: Tue Oct 13, 2009 3:25 pm    Post subject: Reply with quote

Hi pz,

i tried using more_time() but results were chaotic. My program was running smoothly for the first 20-30 seconds, but then it was getting stuck strangely... I talked with my boss and my company has purchased a turbo motion 2

I also send an email to info@ for sample code for turbo motion 2 - pc client communication.
Back to top
View user's profile Send private message
pz
Guest





PostPosted: Wed Oct 14, 2009 2:11 pm    Post subject: Reply with quote

bugra.hasbek wrote:
Hi pz,

i tried using more_time() but results were chaotic. My program was running smoothly for the first 20-30 seconds, but then it was getting stuck strangely... I


It can be that phone is busy on something else and so. If you don't need such short polling then ACTION_STATUS would be better.

Quote:


talked with my boss and my company has purchased a turbo motion 2

I also send an email to info@ for sample code for turbo motion 2 - pc client communication.
Back to top
bugra.hasbek



Joined: 14 Jul 2009
Posts: 26

PostPosted: Wed Oct 21, 2009 4:22 pm    Post subject: Reply with quote

Hi pz,

I got my tm 2. Its rs232 capability has made my job a lot easier Smile

I am still having difficulty with running my program on real time. If i run program in a while(1) loop it runs flawlesly in first 40-50 seconds, then it kinda frozes. I tried your advice about ACTION_STATUS. It is stable and gets the job done, however it is not real-time.

In another message you mentioned about running my program in baby mcu will provide me real-time support. I would like to try it, however i dont know how to do it. I found that, there is a babyloader utility program which uploads programs to baby mcu. Compiling babyloader results in a trb file. I installed trb file to tm2 using cemu. However i dont know how to proceed after that point. I assume I should plug tm2 to PC's rs232 port. What then?

I know I sound like a lazy person but there is limited documentation on turbo motion 2 and i couldnt find how to upload programs. Apologies if it is in the documentations.
Back to top
View user's profile Send private message
pz
Guest





PostPosted: Tue Oct 27, 2009 9:01 am    Post subject: Reply with quote

bugra.hasbek wrote:
Hi pz,

I got my tm 2. Its rs232 capability has made my job a lot easier Smile

I am still having difficulty with running my program on real time. If i run program in a while(1) loop it runs flawlesly in first 40-50 seconds, then it kinda frozes. I tried your advice about ACTION_STATUS. It is stable and gets the job done, however it is not real-time.


How much "real time" you want/need to be? Maybe if you can shed a light on the overall application.

Quote:

In another message you mentioned about running my program in baby mcu will provide me real-time support. I would like to try it, however i dont know how to do it. I found that, there is a babyloader utility program which uploads programs to baby mcu. Compiling babyloader results in a trb file. I installed trb file to tm2 using cemu. However i dont know how to proceed after that point. I assume I should plug tm2 to PC's rs232 port. What then?


TM2 has 2 mcu's: "main" m128 and "baby" m168.

For "main" you use what you know, there is OS, apps, etc. "Main" is sleeping most of time, has no clocks (stopped by phone).

"Baby" is different - you have the whole mcu for you. There is some "os" preinstalled doing what's needed for autoalarm app (rs232, accelerometer) but you can install whatever you want. Loading the resulting binary is done with babyloader, it loads whole "baby" flash. It's in fact standard mcu loader.

"Baby" is running all the time (or as you program in your code), has clocks/xtal. So if you want to do something realtime do it in baby and then fetch it at STATUS by "main" and pass it to the phone.

Quote:

I know I sound like a lazy person but there is limited documentation on turbo motion 2 and i couldnt find how to upload programs. Apologies if it is in the documentations.


You are not lazy at all, our lack of docs.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    bladox.com Forum Index -> Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group