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 

My code doesnt work...any ideas?

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





PostPosted: Tue Jul 03, 2007 7:33 am    Post subject: My code doesnt work...any ideas? Reply with quote

Hi,

I'm playing around with the Turbo BRA and BRUM, trying to make a demonstrator which shows some of the things you can do with the system. One thing I'm trying to do, is to let the user input some number on ME and let the BRUM-leds flash an equal amount of times. My problem is that when I enter, say ,the number 5, I get like 200 or so flashes.

Here is the code for the ME side:
Code:

u8 app_ledflash (SCtx * ctx, u8 action)
{
if (action == APP_ENTER)
  {
    u8 *res;
    int x;
    u8 *r = buf_A ();
    u8 l;

    res = get_input ("Number of flashes (1-9)", 1, 1, NULL, Q_GET_INPUT_DIGITS);
   
   
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;
   
    res[res[0] + 1] = '\0';
    x = atoi (&res[2]);
   
    r = bra_make_head (r, NULL, t_bra_tag3, 1);
   
    *r++ = x ;      //Number of flashes

    l = bra_txrx (buf_A (), r - buf_A (), t_bra_tag, 30, 1, 10);
   
    if (l > 0)
      r = display_text_raw ("WATCH THE LEDS!", Q_DISPLAY_TEXT_DELAY_CLEAR);
    else
      display_text_raw (t_No_Link, Q_DISPLAY_TEXT_USER_CLEAR);

    return APP_BACK;
  }
  return APP_OK;
}



And this is for the BRUM side:

Code:
case ACTION_BRA_RX:
      {
   u8 *buf = data;
   u8 *r;

   r = bra_seek_head (buf, T_BRA_DATA);
   int i = r;
   r = buf;
   r = bra_make_head (r, NULL, t_bra_tag2, 1);
   bra_tx (buf, r - buf);
   
   for (int k = 0; k < i ; k++)

      {
        set_led (1, 1);
        set_led (2, 1);
        set_led (3, 1);
        set_led (4, 1);

        delayMs (30);

 
        set_led (1, 0);
        set_led (2, 0);
        set_led (3, 0);
        set_led (4, 0);
   
        delayMs (30);
      }   
      }
      break;


Does anyone see an error? Could the problem be that I'm using the address of the integer and not the real value in the for-loop?
Back to top
pz
Guest





PostPosted: Tue Jul 03, 2007 7:24 pm    Post subject: Re: My code doesnt work...any ideas? Reply with quote

mundobot wrote:
Hi,

I'm playing around with the Turbo BRA and BRUM, trying to make a demonstrator which shows some of the things you can do with the system. One thing I'm trying to do, is to let the user input some number on ME and let the BRUM-leds flash an equal amount of times. My problem is that when I enter, say ,the number 5, I get like 200 or so flashes.

Here is the code for the ME side:
Code:

u8 app_ledflash (SCtx * ctx, u8 action)
{
if (action == APP_ENTER)
  {
    u8 *res;
    int x;
    u8 *r = buf_A ();
    u8 l;

    res = get_input ("Number of flashes (1-9)", 1, 1, NULL, Q_GET_INPUT_DIGITS);



Not related but avoid "..." as argument - this is in fact allocated in RAM which is scarce. Use PROGMEM for this.

Quote:

Code:

   
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;
   
    res[res[0] + 1] = '\0';
    x = atoi (&res[2]);
   
    r = bra_make_head (r, NULL, t_bra_tag3, 1);
   
    *r++ = x ;      //Number of flashes

    l = bra_txrx (buf_A (), r - buf_A (), t_bra_tag, 30, 1, 10);
   
    if (l > 0)
      r = display_text_raw ("WATCH THE LEDS!", Q_DISPLAY_TEXT_DELAY_CLEAR);
    else
      display_text_raw (t_No_Link, Q_DISPLAY_TEXT_USER_CLEAR);

    return APP_BACK;
  }
  return APP_OK;
}



And this is for the BRUM side:

Code:
case ACTION_BRA_RX:
      {
   u8 *buf = data;
   u8 *r;

   r = bra_seek_head (buf, T_BRA_DATA);
   int i = r;



i=*r; no?

Quote:

Code:

   r = buf;
   r = bra_make_head (r, NULL, t_bra_tag2, 1);
   bra_tx (buf, r - buf);
   
   for (int k = 0; k < i ; k++)

      {
        set_led (1, 1);
        set_led (2, 1);
        set_led (3, 1);
        set_led (4, 1);

        delayMs (30);

 
        set_led (1, 0);
        set_led (2, 0);
        set_led (3, 0);
        set_led (4, 0);
   
        delayMs (30);
      }   
      }
      break;


Does anyone see an error? Could the problem be that I'm using the address of the integer and not the real value in the for-loop?
Back to top
mundobot
Guest





PostPosted: Wed Jul 04, 2007 7:23 am    Post subject: Reply with quote

Quote:
Not related but avoid "..." as argument - this is in fact allocated in RAM which is scarce. Use PROGMEM for this.


Yeah, I know. I just have a bad habit of doing it the easy way in my drafts...


Quote:

i=*r; no?

Bingo! I'm sure I tried that a couple of times without any result, but now it works like a charm. I must have forgotten to save or something before compiling in my previous trials.

Thanks a lot

Btw: Does anybody have any ideas of what to do with the BRA/BRUM system? Some suggestions for my demonstrator perhaps.. At the moment I feel there is very little information out there about the BRUM and I am having trouble doing anything else than some different ways of flashing the leds and pinging for RSSI/LQI.
Back to top
pz
Guest





PostPosted: Fri Jul 06, 2007 10:54 am    Post subject: Reply with quote

Many ideas you can find at zigbee site in their white papers, all the home automation and so. There is/was also an attempt by some italian telco to make zigbee SIM (which we very doubt it may work because of antenna issues, it was our first attempt we tried) with some papers/presentation also on zigbee site.

We hope to release the payment demo from CES'07 soon, proximity payment. We work on proximity marketing and so. In amatus project bra is used to access box with 6 sim cards.

Then there are some project/ideas we cannot speak about yet Sad
Back to top
mundobot
Guest





PostPosted: Fri Jul 06, 2007 1:41 pm    Post subject: Reply with quote

Ok, thanks. I'll give them a read next week. I have another question, though...

At the moment I'm playing around with the set_timer function and I have encountered some problems:

1) I'm specifying the time interval from user input on the ME. This works as long as I input numbers smaller than 10. I have used the same algorithm earlier on some user input and I'm having no problems with numbers larger than 9 there... This is the code:

Code:

    u8 *res;
    u8 h;
    u8 m;
    u8 s;

    res = get_input (t_hours, 1, 2, NULL, Q_GET_INPUT_DIGITS);
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;

    res[res[0] + 1] = '\0';
    h = atoi (&res[2]);
   
    res = get_input (t_minutes, 1, 2, NULL, Q_GET_INPUT_DIGITS);
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;

    res[res[0] + 1] = '\0';
    m = atoi (&res[2]);
   
    res = get_input (t_seconds, 1, 2, NULL, Q_GET_INPUT_DIGITS);
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;

    res[res[0] + 1] = '\0';
    s = atoi (&res[2]);   
   
    timer = timer_start(h,m,s);

Can you see any problems?

2)I also want to implement a function which makes the user able to check the current value of the timer. For this I'm using check_timer, but the problem is that it returns a u32 tag and I don't know what is included in this tag and how to convert it to a string. I have checked the 11.14 standard, but I cant find any info on this tag in my version (downloaded from etsi.org). Do you have any info on this?

All other aspect of the timer works flawlessly as long as I don't input any values larger than 9 for hours, minutes or seconds.
Back to top
pz
Guest





PostPosted: Mon Jul 09, 2007 10:44 am    Post subject: Reply with quote

mundobot wrote:
Ok, thanks. I'll give them a read next week. I have another question, though...

At the moment I'm playing around with the set_timer function and I have encountered some problems:

1) I'm specifying the time interval from user input on the ME. This works as long as I input numbers smaller than 10. I have used the same algorithm earlier on some user input and I'm having no problems with numbers larger than 9 there... This is the code:

Code:

    u8 *res;
    u8 h;
    u8 m;
    u8 s;

    res = get_input (t_hours, 1, 2, NULL, Q_GET_INPUT_DIGITS);
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;

    res[res[0] + 1] = '\0';
    h = atoi (&res[2]);
   
    res = get_input (t_minutes, 1, 2, NULL, Q_GET_INPUT_DIGITS);
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;

    res[res[0] + 1] = '\0';
    m = atoi (&res[2]);
   
    res = get_input (t_seconds, 1, 2, NULL, Q_GET_INPUT_DIGITS);
    if (res == ENULL)
      return APP_END;
    if (res == NULL)
      return APP_BACK;

    res[res[0] + 1] = '\0';
    s = atoi (&res[2]);   
   
    timer = timer_start(h,m,s);

Can you see any problems?


Mmm, no, it seems good (but haven't tested it). What happens if you hardcode the values? How does timer example work? What phone is this? Maybe ME is to blame.

If you enter 0,0,30, i.e. no H/S, is there any difference?

Quote:

2)I also want to implement a function which makes the user able to check the current value of the timer. For this I'm using check_timer, but the problem is that it returns a u32 tag and I don't know what is included in this tag and how to convert it to a string. I have checked the 11.14 standard, but I cant find any info on this tag in my version (downloaded from etsi.org). Do you have any info on this?


u32 returned by timer_value() is 0x00HHMMSS.

Quote:

All other aspect of the timer works flawlessly as long as I don't input any values larger than 9 for hours, minutes or seconds.
Back to top
mundobot
Guest





PostPosted: Tue Jul 10, 2007 10:18 am    Post subject: Reply with quote

Quote:

Mmm, no, it seems good (but haven't tested it). What happens if you hardcode the values? How does timer example work? What phone is this? Maybe ME is to blame.

If you enter 0,0,30, i.e. no H/S, is there any difference?


Tried to hardcode some parameters and it seems to be a problem with the ME. With 0,0,30 I get the same result as when I enter parameters larger than 9. So the problem is not in the algorithm for the input but in the phone. I'm using a Siemens SL65. Maybe this is not a good phone for STK development..I am also having problems with the set_up_call function (I'm kind of trying out every function in your Turbo-docs..) The code is:

Code:
void call_support (SCtx * ctx, u8 action)
{
u8 tlf = "+4712345678";
u8 *ms = str2msisdn (tlf, MSISDN_SMS, MEM_R);
set_up_call (ms, MSISDN_SMS, NULL);
}


It works fine until I press confirm (when the phone asks me for confirmation) but then it just jumps back to the menu without any further actions. Can this be a problem with the phone too? Or is it maybe something with the MSISDN? I didnt know if I should use ADN or SMS, so I tried both without success...

PS: Do you have any suggestions to how I easily can convert the timer_value tag to something easily displayed by display_text_raw? Maybe some way of extracting the HH, MM, SS parts so that I can save them in new variables..?
Back to top
mundobot
Guest





PostPosted: Wed Jul 11, 2007 10:17 am    Post subject: Reply with quote

nevermind the call_support part...I just forgot APP_OK... Embarassed
Back to top
pz
Guest





PostPosted: Wed Jul 11, 2007 12:58 pm    Post subject: Reply with quote

What a shame! Smile

As for siemens 65 - there were rumors this was the model that made siemens to get rid of the phone divison. Otherwise siemenses were great regarding STK, don't know what's wrong with this timer issue.

The u32 returned timer_value() is really just 00HHMMSS, i.e. do something like

u32 x=timer_value();
u8 h=x >>16;
u8 m=x>>8;
u8 s=x;

sprintc(..., '0'+h>>4);
sprintc(..., '0' + (h&0x0f));

etc.
Back to top
pz
Guest





PostPosted: Tue Jul 17, 2007 6:13 am    Post subject: Reply with quote

pz wrote:
Many ideas you can find at zigbee site in their white papers, all the home automation and so. There is/was also an attempt by some italian telco to make zigbee SIM (which we very doubt it may work because of antenna issues, it was our first attempt we tried) with some papers/presentation also on zigbee site.

We hope to release the payment demo from CES'07 soon, proximity payment. We work on proximity marketing and so. In amatus project bra is used to access box with 6 sim cards.

Then there are some project/ideas we cannot speak about yet Sad


For the test version of proximity pay demo see http://www.bladox.com/pub/pay-t1.tar.gz
Back to top
mundobot
Guest





PostPosted: Fri Jul 27, 2007 1:52 pm    Post subject: Reply with quote

Quote:
For the test version of proximity pay demo see http://www.bladox.com/pub/pay-t1.tar.gz


Thanks! Having some trouble making it work, though... When running litepos.exe, nothing happens. If I press Ctrl-Alt-Del I can see the process running (using about 97% of the cpu). Must be some problem with my window-environment.

Anyhow, I was having an idea for my demonstrator project. I was hoping to do something similar to the Turbo Lite 2 pager application, but in this case using the BRA/BRUM. In short terms I wish to connect some kind of sensor to the BRUM and be able to check its status with the mobile phone. The type of sensor is not important, I just want to convert some voltage on one of the BRUM pins into some value, which then can be downloaded to ME by using BRA. Is this achievable?

My biggest problem is the lack of information about the BRUM. I have found no technical datasheet, so I have no idea which pins are connected to what and nothing on how to make the BRUM a standalone operating unit (make it work without connecting it to the Programmer) . I can also see some trouble with the adc. Do you have more info on this? I have a quite clear picture on how the program should be structured up to the pins and adc part.. Is support for pin-usage something that is going to be include in the official release of the BRUM devel-docs? And when is this going to be released?
Back to top
pz
Guest





PostPosted: Sat Jul 28, 2007 6:19 am    Post subject: Reply with quote

mundobot wrote:
Quote:
For the test version of proximity pay demo see http://www.bladox.com/pub/pay-t1.tar.gz


Thanks! Having some trouble making it work, though... When running litepos.exe, nothing happens. If I press Ctrl-Alt-Del I can see the process running (using about 97% of the cpu). Must be some problem with my window-environment.


Are you sure you edited litepos.cfg and specified com port?

Quote:

Anyhow, I was having an idea for my demonstrator project. I was hoping to do something similar to the Turbo Lite 2 pager application, but in this case using the BRA/BRUM. In short terms I wish to connect some kind of sensor to the BRUM and be able to check its status with the mobile phone. The type of sensor is not important, I just want to convert some voltage on one of the BRUM pins into some value, which then can be downloaded to ME by using BRA. Is this achievable?


Yes, sure.

Quote:

My biggest problem is the lack of information about the BRUM. I have found no technical datasheet, so I have no idea which pins are connected to what and nothing on how to make the BRUM a standalone operating unit (make it work without connecting it to the Programmer) . I can also see some trouble with the adc. Do you have more info on this?


You mean m128 ADC in general or adc example? Also take a look at Pager or AA code, adc is used there.

BRUM needs just power to run, we will try to prepare some doc.

Quote:

I have a quite clear picture on how the program should be structured up to the pins and adc part.. Is support for pin-usage something that is going to be include in the official release of the BRUM devel-docs? And when is this going to be released?


Sorry for being lazy, writer's block as always when preparing some "official" documentation. But in this case atmel m128 datasheet should do, m128 pins go straight to "brum" holes/pins.
Back to top
mundobot
Guest





PostPosted: Mon Jul 30, 2007 8:18 am    Post subject: Reply with quote

Quote:

You mean m128 ADC in general or adc example? Also take a look at Pager or AA code, adc is used there.


After looking through the m128 datasheet, I feel I have a better understanding of the adc. For my project, the adc_measure in the adc example should be sufficient with very few alterations? I just need to read off one voltage at one pin (maybe more later) at the users request.

Quote:

BRUM needs just power to run, we will try to prepare some doc.


That would be great, but at the moment, all the information I need is the location of Vcc, Gnd, Avcc and adc0-adc3. The locations of the supply-voltage-pins are especially difficult to find by inspecting the card and comparing it to the m128 datasheet. A simple figure would be nice Smile
Back to top
pz
Guest





PostPosted: Fri Aug 03, 2007 7:38 pm    Post subject: Reply with quote

See http://www.bladox.com/doc/brum_pinout-r01070803.pdf

As for AVCC - Vcc is used, it's connected also to ADC0 to measure battery/VCC, so use other ADCx.

What about the Pay demo - were you able to modify litepos.cfg? Did it help? We want to post it soon so any feedback is appreciated.
Back to top
mundobot
Guest





PostPosted: Sat Aug 04, 2007 10:55 am    Post subject: Reply with quote

Quote:
See http://www.bladox.com/doc/brum_pinout-r01070803.pdf

As for AVCC - Vcc is used, it's connected also to ADC0 to measure battery/VCC, so use other ADCx.


Great! I actually found the pins I needed myself and managed to build a card from which the BRUM could operate. I have been testing it the last couple of days and it works great. Anyway, your document raises a few questions..

First of all, I'm using a 4,5 V adapter as a powersupply. This is connected directly to VCC and GND. In your document I see you have specified VCC to be in the range 2,7 - 3,3 V. Is it damaging to BRUM to connect it to 4,5 V? As I said, I have been using the card on 4,5 V a couple of days now and I have had no problems at all. Looking through the atmel datasheet, I can see that the MCU can handle voltages up to about 5,5 V, so the atmel should not be damaged. Is there any other components that could take damage of the high voltage? Radio chip perhaps? I have had no problems with the radio during testing and I actually get an improvement in range when I connect the BRUM to my own card in stead of the Programmer 2 (noise reduction perhaps..)

I have also been using ADC0 for some analog input. I see now that I shouldn't. I will probably turn this into some measurement of VCC. On the ADC3 I have soldered a thermistor and I have created a program which convert the voltages into degrees celsius and displays the on ME. This is working flawlessly, except that I'm missing a way to convert floating-point numbers to string. I understand that sprintf is not ported, so I all I can do at this point is casting my float as an integer and append it to buffer using sprinti. It would have been great to display at least have one decimal though...

Quote:
What about the Pay demo - were you able to modify litepos.cfg? Did it help? We want to post it soon so any feedback is appreciated.


Sorry, I spent all my time on the BRUM-board. Will have a look when I get back to work on Monday, but I'm pretty sure that I edited the config before launching the program.
EDIT: I checked and I had edited the config correctly...Program still not working. Sad
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