From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with data receive in TCP/IP

You can certainly do that.  But I'm sure you can send the data as bytes and not just as ASCII strings.

 

If you attached your C code, someone may help.  (though this is a LabVIEW forum and not a C forum.)

 

In Basic, if you want to print a non-printable character, you'd print out something like chr$(10) which is the new line/linefeed character.  I'm sure C has some equivalent function.

Message 11 of 14
(970 Views)

I am searching for the solution in ARM related forums. The ethernet library which I used, is utilizing a high level function for data sending. There must be some low-level functions to send bytes instead of string. I can not shift or replace ASCII characters, becuase I need the complete 0 to 255 values to send numeric data.

Thanks.

0 Kudos
Message 12 of 14
(959 Views)

@iman_h wrote:

I am searching for the solution in ARM related forums. The ethernet library which I used, is utilizing a high level function for data sending. There must be some low-level functions to send bytes instead of string. I can not shift or replace ASCII characters, becuase I need the complete 0 to 255 values to send numeric data.

Thanks.


It's hard to believe the library would require you to send ASCII.  That would make it almost totally useless.  How would you use this library to download a zip file, for instance?  Remember also that you would have to have a decoder on the other side to decode the ASCII back into a binary string.  In other words, a version of this library would have to exist on every single thing it is communicating with.

 

I think you are unnecessarily hung up on the fact that it is sending strings.  Sending a string is just a way to send bytes of data.  Remember, a string can contain non-printable characters, too.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 13 of 14
(946 Views)

Let me attach some piece of code:

Spoiler
// buffer is an array of uint8_t
// In library prototype, the data is sent like this:
sprintf(str,"%s\n\r\n\r",buffer);
plen=fill_tcp_data_p(buf,0,(const unsigned char *)(str));

make_tcp_ack_from_any(buf); // send ack for http get
make_tcp_ack_with_data(buf,plen); // send data

These are the definition of functions:

Spoiler
unsigned int fill_tcp_data_p(unsigned char *buf,unsigned int pos, const unsigned char *progmem_s)
{

char c;

// fill in tcp data at position pos
//
// with no options the data starts after the checksum + 2 more bytes (urgent ptr)
while ((c = pgm_read_byte(progmem_s++)))
{
buf[TCP_CHECKSUM_L_P+3+pos]=c;
pos++;
}
return(pos);
}

 

As I understood, when we fill buffer like this:

buffer[5]={48,64,112,0,65};

It is converted into a string like this:

str=0 @ p \0 A

I think the \0 between the array of characters, make the function terminate the string and send: 0 @ p. (Three bytes instead of 5 bytes)

0 Kudos
Message 14 of 14
(938 Views)