problem send string to usart [WSN]

Go To Last Post
36 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi......
i want to send string from router to coordinator but i can`t please help me:
in WSNDemoApp.h i add char *pm; to struct like below:

typedef struct
{
  uint8_t     messageType;
  uint8_t     nodeType;
  ExtAddr_t   extAddr;
  ShortAddr_t shortAddr;
  uint32_t    softVersion;
  uint32_t    channelMask;
  PanId_t     panID;
  uint8_t     workingChannel;
  ShortAddr_t parentShortAddr;
  uint8_t     lqi;
  int8_t      rssi;
  //additional field
  uint8_t     boardType;//1
  uint8_t     sensorsSize;//1
  char       *pm;
  struct {
    int32_t  battery;
    int32_t  temperature;
    int32_t  light;
  } meshbean;
} PACK AppMessage_t;
and in Router.c i write this code:

    case READING_SENSORS_STATE:
      switch (event)
      {
        case APP_PROCESS:
		appMessage.data.pm="hello"; 
          appReadLqiRssi();

is any thing wrong?! because i cant see this string or hex code in my serial port program...

Last Edited: Fri. Oct 16, 2015 - 02:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are sending pointer to a string. Of course it comes up like a hex number. You need to put something like

char pm[10];

.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for answer:)
char pm[10];
yes i use it and initial this with this code :
appMessage.data.pm[0]='h';
appMessage.data.pm[1]='e';
appMessage.data.pm[2]='l';
appMessage.data.pm[3]='l';
appMessage.data.pm[4]='o';
and its work i dont know why i cant initial pm like this!!!:
appMessage.data.pm="hello";
************
actually i want daynamic array! what can i do for that?:( thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

i dont know why i cant initial pm like this!!!:
appMessage.data.pm="hello";

Surely you mean:

strcpy(appMessage.data.pm, "hello");

C has never supported string assignment.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nta_xyz wrote:
and its work i dont know why i cant initial pm like this!!!:

Because it does not make any sense from the C languale perspective. You may do something like this:
memcpy(appMessage.data.pm, "hello", 5);

nta_xyz wrote:
actually i want daynamic array! what can i do for that?:( thanks
Form the message payload dynamically, obviously.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wo0o0o0www thanksssssssssss alexru
memcpy(appMessage.data.pm, "hello", 5);
....its worked.!:)

sorry i have another question:)
in wsndemo i can send data form router to coordinator but i want send data from coordinatoor to router i work like this:
in WSNRouter.c i write this:
case INITIAL_DEVICE_STATE:
switch (event)
{
case APP_PROCESS:

//*****************
// Prefilling request parameters
messageParams.profileId = simpleDescriptor.AppProfileId;
messageParams.dstAddrMode = APS_SHORT_ADDRESS;
messageParams.dstAddress.shortAddress = CPU_TO_LE16(0);
messageParams.dstEndpoint = 1;
messageParams.clusterId = CPU_TO_LE16(1);
messageParams.srcEndpoint = simpleDescriptor.endpoint;
messageParams.asduLength = sizeof(appMessage.data.coord);
messageParams.asdu = (uint8_t *)(&appMessage.data.coord);
messageParams.txOptions.acknowledgedTransmission = 1;
#ifdef _APS_FRAGMENTATION_
messageParams.txOptions.fragmentationPermitted = 1;
#endif
#ifdef _HIGH_SECURITY_
messageParams.txOptions.securityEnabledTransmission = 1;
#endif
messageParams.radius = 0x0;
messageParams.APS_DataConf = APS_DataConf;
and in case reading sensor state i write this:
case READING_SENSORS_STATE:
switch (event)
{
case APP_PROCESS:
appMessage.data.coord[0]='s';
appMessage.data.coord[1]='e';
appMessage.data.coord[2]='n';
appMessage.data.coord[3]='t';

APS_DataReq(&messageParams);

and in WSNrouter.c :
void APS_DataIndRouter(APS_DataInd_t *indData)
{
unit8_t msg;
msg=(unit8_t *)indData->asdu;
}

is any thing wrong?!
i think my endpoint is wrong! please help me..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
and its work i dont know why i cant initial pm like this!!!:
Initialization using a literal string can only be done when the variable is defined.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nta_xyz wrote:
in wsndemo i can send data form router to coordinator but i want send data from coordinatoor to router i work like this:
in WSNRouter.c i write this:
You mean WSNCoord.c?

Then here:

messageParams.dstAddress.shortAddress = CPU_TO_LE16(0);

instead of 0 you need to provide router's address.

And when you say that something does not work, please be more specific on how exactly it does not work and what you have expected instead.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alexru wrote:
nta_xyz wrote:
in wsndemo i can send data form router to coordinator but i want send data from coordinatoor to router i work like this:
in WSNRouter.c i write this:
You mean WSNCoord.c?

Then here:

messageParams.dstAddress.shortAddress = CPU_TO_LE16(0);

instead of 0 you need to provide router's address.

And when you say that something does not work, please be more specific on how exactly it does not work and what you have expected instead.

thanks again for answer me:)
yes sorry i write wrong i mean WSNcoord.c

router CS_UID = 0x3LL so this mean i must write like this?:

messageParams.dstAddress.shortAddress = 0000000000000003;

is it correct?

i expect coordinator send char pm[20]; to router then router write this to

typedef struct
{
  uint8_t     messageType;
  uint8_t     nodeType;
  ExtAddr_t   extAddr;
  ShortAddr_t shortAddr;
  uint32_t    softVersion;
  uint32_t    channelMask;
  PanId_t     panID;
  uint8_t     workingChannel;
  ShortAddr_t parentShortAddr;
  uint8_t     lqi;
  int8_t      rssi;
  //additional field
  uint8_t     boardType;//1
  uint8_t     sensorsSize;//1
  char        pm[20];
  struct {
    int32_t  battery;
    int32_t  temperature;
    int32_t  light;
  } meshbean;
} PACK AppMessage_t;

with code you tell me :

memcpy(appMessage.data.pm, ????!!, 20);

so for check to it work correctly i can see my message when router send PACK AppMessage_t; to coordinator then coordinator send it to pc with uart...

:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and if i want to broadcast a message to all of nodes what must i do?!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nta_xyz wrote:

messageParams.dstAddress.shortAddress = 0000000000000003;

is it correct?

No, CS_UID is an extended address. You need to provide short address. To find out the shoer address of the device you need to send ZDP request providing known extended address.

nta_xyz wrote:
and if i want to broadcast a message to all of nodes what must i do?!

Use:
messageParams.dstAddress.shortAddress = 0xffff;

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i do this:
in WSNCoord.c:

  case READING_SENSORS_STATE:
      switch (event)
      {
        case APP_PROCESS:
		memcpy(appMessage.data.pm,"data",4);

          appReadLqiRssi();
          appStartSensorManager();
          appGetSensorData(appSensorsesGot);
          break;
case SENDING_DEVICE_STATE:
      switch (event)
      {
        case APP_PROCESS:

		APS_DataReq(&messageParams);
         
		  visualizeSerialTx();
		 
          appSendMessageToUsart(&appMessage.data);
          appDeviceState = STARTING_TIMER_STATE;
          appPostSubTaskTask();
          break;
case INITIAL_DEVICE_STATE:
      switch (event)
      {
        case APP_PROCESS:
          HAL_StopAppTimer(&deviceTimer);

          deviceTimer.interval = APP_TIMER_SENDING_PERIOD;
          deviceTimer.mode     = TIMER_ONE_SHOT_MODE;
          deviceTimer.callback = deviceTimerFired;
		  //*****************
	      messageParams.profileId               = simpleDescriptor.AppProfileId;
          messageParams.dstAddrMode             = APS_SHORT_ADDRESS;
          messageParams.dstAddress.shortAddress = 0xFFFF;
          messageParams.dstEndpoint             = 1;
          messageParams.clusterId               = CPU_TO_LE16(1);
          messageParams.srcEndpoint             = simpleDescriptor.endpoint;
          messageParams.asduLength              = sizeof(appMessage.data);
          messageParams.asdu                    = (uint8_t *)(&appMessage.data);
          messageParams.txOptions.acknowledgedTransmission = 1;
#ifdef _APS_FRAGMENTATION_
          messageParams.txOptions.fragmentationPermitted = 1;
#endif
#ifdef _HIGH_SECURITY_
          messageParams.txOptions.securityEnabledTransmission = 1;
#endif          
          messageParams.radius                  = 0x0;
          messageParams.APS_DataConf            = APS_DataConf;
		  //**********************
          appDeviceState = READING_SENSORS_STATE;
          appPostSubTaskTask();
          break;
static void APS_DataConf(APS_DataConf_t *confInfo)
{
if (APS_SUCCESS_STATUS == (confInfo->status) )
{
memcpy(appMessage.data.pm2,"sent",4);
}

}

And in wsnRouter.c for i know data arrived i write this:

void APS_DataIndRouter(APS_DataInd_t *indData)
{
memcpy(appMessage.data.pm2,"in function",11);
  indData = indData;
}

but i dont know why APS_DataIndRouter function does not start because if this function start i see "in function" in my c# program...and when i program router with this codes led red and green just fast blinking!!

i expected the coordinator send data to router but it is not work.!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can't ask for an ACK for the broadcast frame. Set:

messageParams.txOptions.acknowledgedTransmission = 0;

In APS_DataConf() you may get transmission status, if something does not work - check it first, it might tell you what the problem is.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

really thanks its worked:)......
i write a new pack for message and as you say

messageParams.txOptions.acknowledgedTransmission = 0;

then its work...thanks :).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi:) im back again:)

in WSNuartmanager.c in readByteEvent function i write this:

//global variable
int cnt=0;
char tmp[50];

//********************

static void readByteEvent(uint16_t readBytesLen)
{
  
READ_USART(&usartDescriptor,  rxBuffer, readBytesLen);
memcpy(tmp,(char *)rxBuffer,49);
cnt=strlen(tmp);

if(tmp[cnt-1]=='*')
{
tmp[cnt-1]=' ';
BroadCast(tmp);//broadcast tmp to all nodes
}

}

uint8_t rxBuffer[USART_RX_BUFFER_LENGTH];
and
USART_RX_BUFFER_LENGTH=64;

i send "hello*" from pc to coordinator and coorectlly send and show me in pc "hello" but when send another string to coordinator like "word*" in pc i get nothing!! when i close serial port in pc(serilport.close()) and then open int(serialport.open()) i get this: "hello*word"
but i expect show me only "word"!!!
i think rxBuffer must be empty for next send string..but i dont know how i can do this...if this is correct please guide me thanks..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If here:

nta_xyz wrote:

READ_USART(&usartDescriptor,  rxBuffer, readBytesLen);
memcpy(tmp,(char *)rxBuffer,49);
cnt=strlen(tmp);

you are reusing rxBuffer from the USART descriptor, then you are wrong, you shall not do this. Instead read directly into the buffer:

READ_USART(&usartDescriptor,  tmp, readBytesLen);
cnt=strlen(tmp);

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ALEXRU YOU ARE STRENUOUS..........:)
same as other your answers worked fine:)......
yes i had mistake read from rxBuffer and then write to it again!!!:O:l.......

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

but i still can not see my second string until close serial port and open it again:(...i do not know why:(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nta_xyz wrote:
but i still can not see my second string until close serial port and open it again:(...i do not know why:(
Then describe what exactly you are sending and receiving and how all devices are connect.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

in wsnuartmanager.c:

//global variable
char tmp[64];
int cnt=0;

//********************
static void readByteEvent(uint16_t readBytesLen)
{
int i;
static uint8_t tmpbuff[USART_RX_BUFFER_LENGTH];
  
READ_USART(&usartDescriptor, tmpbuff, readBytesLen);

strcat(tmp,(char *)tmpbuff);
cnt=strlen(tmp);
memcpy(appMessage.data.pm,tmp,49);
if(tmp[cnt-1]=='*')
{
tmp[cnt-1]='\0';
BroadCast(tmp);  //broadcast tmp to all nodes 
  for(i=0;i<64;i++)
   {
    tmp[i]='\0';
   }
}

}

} 
void appStartUsartManager(void)
{
  usartDescriptor.tty            = USART_CHANNEL;
  usartDescriptor.mode           = USART_MODE_ASYNC;
  usartDescriptor.flowControl    = USART_FLOW_CONTROL_NONE;
  usartDescriptor.baudrate       = USART_SPEED;
  usartDescriptor.dataLength     = USART_DATA8;
  usartDescriptor.parity         = USART_PARITY_NONE;
  usartDescriptor.stopbits       = USART_STOPBIT_1;
  usartDescriptor.rxBuffer       = rxBuffer;
  usartDescriptor.rxBufferLength = USART_RX_BUFFER_LENGTH;
  usartDescriptor.txBuffer       = NULL;
  usartDescriptor.txBufferLength = 0;
  usartDescriptor.rxCallback     = readByteEvent;
  usartDescriptor.txCallback     = writeConfirm;

  OPEN_USART(&usartDescriptor);

  memset(&wsn2usart, 0, sizeof(wsn2usart));
  wsn2usart.isFreeUsart = true;
}

in coord.c:

  case INITIAL_DEVICE_STATE:
      switch (event)
      {
        case APP_PROCESS:
          HAL_StopAppTimer(&deviceTimer);

          deviceTimer.interval = APP_TIMER_SENDING_PERIOD;
          deviceTimer.mode     = TIMER_ONE_SHOT_MODE;
          deviceTimer.callback = deviceTimerFired;
		  //***********************
		            // Prefilling request parameters
          messageParams.profileId               = simpleDescriptor.AppProfileId;
          messageParams.dstAddrMode             = APS_SHORT_ADDRESS;
          messageParams.dstAddress.shortAddress = 0xFFFF;//broadcast 
          messageParams.dstEndpoint             = 1;
          messageParams.clusterId               = CPU_TO_LE16(1);
          messageParams.srcEndpoint             = simpleDescriptor.endpoint;
          messageParams.asduLength              = sizeof(SmsReq.data);
          messageParams.asdu                    = (uint8_t *)(&SmsReq.data);
          messageParams.txOptions.acknowledgedTransmission = 0;//chon broadcast e
#ifdef _APS_FRAGMENTATION_
          messageParams.txOptions.fragmentationPermitted = 1;
#endif
#ifdef _HIGH_SECURITY_
          messageParams.txOptions.securityEnabledTransmission = 1;
#endif          
          messageParams.radius                  = 0x0;
          messageParams.APS_DataConf            = APS_DataConf;
		  //************************
		  

          appDeviceState = READING_SENSORS_STATE;
          appPostSubTaskTask();
          break;

void BroadCast(char tmp[])
{
messageParams.dstAddress.shortAddress = 0xFFFF;
messageParams.txOptions.acknowledgedTransmission = 0;
		  //***************
		memcpy(SmsReq.data.payam,tmp,49);
		APS_DataReq(&messageParams);
}

in wsndemoapp.h:

BEGIN_PACK
typedef struct
{
  char        payam[50];
} PACK Sms_t;

typedef struct
{
  uint8_t        header[APS_ASDU_OFFSET];
  Sms_t   data;
  uint8_t        footer[APS_AFFIX_LENGTH - APS_ASDU_OFFSET];
} PACK SmsReq_t;
END_PACK

in my pc:
//c# code//

private void btnsend_Click(object sender, EventArgs e)
{
    int i=0,stlen;;
    string sttmp;
    sttmp =txtsend.Text+"*";
    stlen = sttmp.Length;
    while (i < stlen)
    {
        serialPort1.Write(sttmp[i].ToString());
        i++;
    }
    MessageBox.Show("Sent Successfull");
}

thanks:(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i describe my problem again:

when i send string for once its recive in router fine but when i send another string after that,, the second string did not send until i close serial port(serialport.close()) and open it again...(serialport.open())
!!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well I don't know anything about C# to begin with. Check that readByteEvent() is called the second time at all.

And also you don't sent 0 at the end of the string and you program counts on it.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i checked it now but readByteEvent() did not call for second time !!!!:(

i think if i do this:
for(i=0;i<64;i++)
{
tmp[i]='\0';
}
the strcat(tmp,(char *)tmpbuff); for second time
tmp is empty.....
is there another way to empty char tmp[64]?:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nta_xyz wrote:
i checked it now but readByteEvent() did not call for second time !!!!:(
Then don't do any processing of the received data at all and first debug your system to receive bytes at any time. Then enable all the processing back.

strcat() will expect tmpbuff to be ended with 0, which is not true in your case for the second time.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Then don't do any processing of the received data at all and first debug your system to receive bytes at any time. Then enable all the processing back.

until i close serial port and open it again in c# program second string did not recived:(
Quote:

strcat() will expect tmpbuff to be ended with 0, which is not true in your case for the second time.

what can i do for this:(?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i used this function 'HAL_Delay' of bitcloud for delay of lib lcd but avr studio give me this error do you know why?! src/lcd_drv.c:16: warning: implicit declaration of function 'HAL_Delay'

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nta_xyz wrote:
i used this function 'HAL_Delay' of bitcloud for delay of lib lcd but avr studio give me this error do you know why?! src/lcd_drv.c:16: warning: implicit declaration of function 'HAL_Delay'

Because there is no prototype for that function. Include halRfCtrl.h if you want to use it.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for answer:)

i fill char hex[6] with a string like this:"0xFFFF"
i want convert it to unit16_t for this:
messageParams.dstAddress.shortAddress

how can i do it?:)
because i want to set
messageParams.dstAddress.shortAddress
dynamic from usart......

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nta_xyz wrote:
how can i do it?:)
It is not BitCloud related, so it is off topic here.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

how can i do it?

This is a cross post - you already started another thread asking about this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry:) ok....

ALEXRU i really thanks for useful answers to me:)and you really help me to complete my project ...

and i use atoi fo cast string to int:) and it is worked:)........

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi...
i have a problem and because my problem has relation with this topic i write it here:

when i call this in WSNCOORD.c:

appSendMessageToUsart((AppMessage_t *)indData->asdu);

((size of APPMessage_t is 56 byte))
for first time when i call this function with first 56 bytes i Recieve only 4-5 bytes of that in my pc and then i call appSendMessageToUsart((AppMessage_t *)indData->asdu); for second time with second 56 bytes i Recieve next 4-5 byte of first 56 bytes!!

i expect each time i call appSendMessageToUsart i recieve full of 56 bytes of AppMessage_t....please guide me...thanks.....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Something is wrong with your receiving code, UART can't store or hold data (without flow control, of course, but it is disabled by default in WSN Demo), so once first byte is out - everything else will be sent too.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

may this problem is for max232?!

i write receiving code here can you see something wrong in this codes:(?

#define MAX_USART_MESSAGE_QUEUE_COUNT 5

static uint8_t rxBuffer[USART_RX_BUFFER_LENGTH];
USART_RX_BUFFER_LENGTH=50;
void appStartUsartManager(void)
{
  usartDescriptor.tty            = USART_CHANNEL;
  usartDescriptor.mode           = USART_MODE_ASYNC;
  usartDescriptor.flowControl    = USART_FLOW_CONTROL_NONE;
  usartDescriptor.baudrate       = USART_SPEED;
  usartDescriptor.dataLength     = USART_DATA8;
  usartDescriptor.parity         = USART_PARITY_NONE;
  usartDescriptor.stopbits       = USART_STOPBIT_1;
  usartDescriptor.rxBuffer       = rxBuffer;
  usartDescriptor.rxBufferLength = USART_RX_BUFFER_LENGTH;
  usartDescriptor.txBuffer       = NULL;
  usartDescriptor.txBufferLength = 0;
  usartDescriptor.rxCallback     = readByteEvent;
  usartDescriptor.txCallback     = writeConfirm;

  OPEN_USART(&usartDescriptor);

  memset(&wsn2usart, 0, sizeof(wsn2usart));
  wsn2usart.isFreeUsart = true;
}

void appSendMessageToUsart(AppMessage_t *newMessage)
{
  UsartMessage_t *msg;
  uint8_t *p, *q, summ, i;
  q = (uint8_t *)newMessage;
  summ = 0;

  if (wsn2usart.size < MAX_USART_MESSAGE_QUEUE_COUNT)
  {
    wsn2usart.size++;
    msg = &wsn2usart.usartMessageQueue[wsn2usart.tail];
    if (++wsn2usart.tail >= MAX_USART_MESSAGE_QUEUE_COUNT)
      wsn2usart.tail -= MAX_USART_MESSAGE_QUEUE_COUNT;

    p = msg->payload;
    *p++ = 0x10;
    *p++ = 0x02;
    for (i = 0; i < sizeof(AppMessage_t); i++)
    {
      if (*q == 0x10)
      {
        *p++ = 0x10;
        summ += 0x10;
      }
      summ += *q;
      *p++ = *q++;
    }
    *p++ = 0x10;
    *p++ = 0x03;
    summ += 0x10 + 0x02 + 0x10 + 0x03;
    *p++ = summ;

    msg->size = p - msg->payload;
  }

  //check sending state
  if (true == wsn2usart.isFreeUsart)
  {
    sendNextMessage();
  }
}

static void sendNextMessage(void)
{
  if (wsn2usart.size)
  {
    WRITE_USART(&usartDescriptor,
      wsn2usart.usartMessageQueue[wsn2usart.head].payload,
      wsn2usart.usartMessageQueue[wsn2usart.head].size
    );
  }
}
static void writeConfirm(void)
{
  if (wsn2usart.size)
  {
    wsn2usart.size--;
    if (++wsn2usart.head >= MAX_USART_MESSAGE_QUEUE_COUNT)
      wsn2usart.head -= MAX_USART_MESSAGE_QUEUE_COUNT;
  }
  wsn2usart.isFreeUsart = true;
  //send next message
  sendNextMessage();
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
may this problem is for max232?!
No, max232 is just a level converter.

Quote:
i write receiving code here can you see something wrong in this codes:(?
Code looks like standard WSNDemo code, it works.

Most likely problem is on PC side, look there.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Most likely problem is on PC side, look there.

yes it was for my program in pc,, coordinator data buffered in pc!!!
now i fix that.... thanks...