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 

BRUM -> programmer communication

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





PostPosted: Sun Nov 19, 2006 11:58 pm    Post subject: BRUM -> programmer communication Reply with quote

Hi

I'm trying to transmit data between a BRUM application and a desktop client - starting from the brum.trb and ping examples, with not too much success so far (tried __dbs, uart_dir_tx then uart_put_char, usb_put_char_nb on the "ping" side, then usb_put_char_nb on the "brum" side but I don't seem to receive anything ...)

I know that this stuff is still under development, but somebody has already tried that or if it just can't work please feel free to englighten me Razz

note : an alternative solution (using only the radio part of BRUM - i.e. with no application running, like a (big) radio USB dongle) would be fine for me as well - not tried that yet (a small doc on the BRUM specific actions for the programmer and especially the action triggered when data is received would be appreciated for that purpose Wink)

Cheers

Nicolas
Back to top
pz
Guest





PostPosted: Mon Nov 20, 2006 10:27 am    Post subject: Reply with quote

Look at brum module and brum_apps.c in turbo-prog-utils-3.1.7. You need to have similar module for prog that will just pass data between brum/pc. I.e. you develop pc application, prog module and brum app. pc<->prog<->brum.

brum application may look like this:

Code:

void my_rx(u8 * buf)
{
u8 i;
u8 *r = buf;
u8 len;
u8 src[4];

/*
for example - process packet you got from radio
r = bra_seek_head (buf, T_BRA_SRC);
for(i=0;i<4;i++)src[i]=r[i];
r = bra_seek_head (buf, T_BRA_DATA);
len=r-buf;
len=buf[0]-len;
*/

uart_dir_tx();
uart_put_char(len_what_send_to_pc);
... send what you want to pc

uart_dir_rx();
len=uart_get_char(); // len of data from pc
r = bra_make_head (buf, src, t_bra_tag, 1);
for(i=0;i<len;i++)*r++=uart_get_char(); // get data from pc
bra_tx (buf, r - buf);
}

void turbo_handler (u8 action, void *data)
{
  switch (action)
  {
    case ACTION_APP_REGISTER:
      reg_bra_tag (t_bra_tag);
      break;
    case ACTION_BRA_RX:
        my_rx(data);
      break;

    default:
      break;
  }
}


Your app simply sends some data to pc (when received by radio) and gets some data from pc. Module in prog just passes it to usb.

Code:

void turbo_handler (u8 action, USB_Data * data)
{
  u8 *buf = buf_A ();
  u16 i;
  u8 tmpC;
  u16 tmpI;

  switch (action)
  {
    case ACTION_APP_VERSION:
      data->buf[0] = VERSION_A;
      data->buf[1] = VERSION_B;
      data->buf[2] = VERSION_C;
      break;

    case ACTION_BRUM_INIT:
      reg_action (ACTION_SIG_UART1_RECV);
      init_brum ();
      init_brum2i2c (MY_SLAVE_ADDRESS);
      usb_send (NO_ERROR, 0, NULL);
      break;
    case ACTION_BRUM_SET_BRUM1_SEL:
      if (data->buf[0] != 0)
      {                         //BRUM1_SEL   //set pin to log.1
        sbi (BRUM1_SEL_PORT, BRUM1_SEL_PORT_PIN);
      }
      else
      {                         //BRUM1_SEL   //set pin to log.0
        cbi (BRUM1_SEL_PORT, BRUM1_SEL_PORT_PIN);
      }
      usb_send (NO_ERROR, 0, NULL);
      break;

    case ACTION_BRUM_SET_BRUM2_SEL:
      if (data->buf[0] != 0)
      {                         //BRUM2_SEL   //set pin to log.1
        sbi (BRUM2_SEL_PORT, BRUM2_SEL_PORT_PIN);
      }
      else
      {                         //BRUM2_SEL   //set pin to log.0
        cbi (BRUM2_SEL_PORT, BRUM2_SEL_PORT_PIN);
      }
      usb_send (NO_ERROR, 0, NULL);
      break;
    case ACTION_SIG_UART1_RECV:
      brum_uart_irq ();
      break;

case ACTION_BRUM_RX:
{
u8 len;
led_on(2);
        while(brumUartRxChars()==0);
        len = brumUartRxGetChar ();
led_on(3);

  for (i = 0; i < len; i++)
        {
        while(brumUartRxChars()==0);
        buf[i] = brumUartRxGetChar ();
        }
led_on(3);

      usb_send (NO_ERROR, len, buf);
}
        break;

case ACTION_BRUM_TX:
{
u8 i=data->buf[0];

data->buf[0]=data->len;

led_on(5);
brumUartTxSendData (data->buf, 1);
data->buf[0]=i;
brumUartTxSendData (data->buf, data->len);
led_on(4);
      usb_send (NO_ERROR, 0, buf);
}
      break;

    default:
      break;
  }
}


It's excerpt from some project but the idea should be clear.
Back to top
nbasim
Guest





PostPosted: Mon Nov 20, 2006 10:42 am    Post subject: Reply with quote

Thanks, should exactly do the trick (missed that because I thought the ACTION_BRUM_TX_DATA was something related to the radio and not serial comm). Will try it tonight.
Back to top
nbasim
Guest





PostPosted: Mon Nov 20, 2006 11:58 pm    Post subject: Reply with quote

Finally got it - I was a little bit confused because I thought the RX action was an OS callback, and not supposed to be called by the client Embarassed

Thanks for the help Cool
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