Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7694477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:19:47+00:00 2026-05-31T21:19:47+00:00

I am writing a code for modbus protocol, that runs on a MSP430 controller.

  • 0

I am writing a code for modbus protocol, that runs on a MSP430 controller. The response buffer(global) is an array of 8bit data, through which the response to the processed request is to be sent on serial UART.
Now, my problem is that the response generated is having a combination of different data types. i.e uint8, uint32, float.
How to send this data by using the global response buffer?

For float, i have tried using memcpy and this seems to be working fine. Is there any better and efficient way? Cuz the frame size is large (say 20-30 bytes). Here is a demo of what i’ve tried to do

int main() 
{ unsigned char buff[8]; //Global buffer 

float temp[2]; //temp buffer to store response values 

temp[0] = 0x00ef2212; 

memcpy(buff, temp, 8); 

printf("buff[0]= %u \n buff[1]= %u\n buff[2] = %u\n buff[3]= %u\n", buff[0],buff[1],buff
[2],buff[3]); 

return 0; 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:19:48+00:00Added an answer on May 31, 2026 at 9:19 pm

    With casting and assignment. E.g.

    uint8 *globalbuf;
    uint32 myval;
    *(uint32*)globalbuf = myval;
    

    copies myval into the first 4 bytes of globalbuf.

    Beware of alignment issues: it may be illegal or expensive on your platform to assign or read values to/from addresses that aren’t whole multiples of that type size. For example address 0,4,8 etc. are OK places to put a uint32.

    This assumes your globalbuf starts on a nice round address..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing code that runs all sorts of external commands as well as various
I'm writing code that runs on Google App Engine (Java). What I'm trying to
I am writing code that will migrate some data from one database to another,
While writing code in a file that would comprise of PHP, HTML, CSS &
I'm writing code that looks similar to this: public IEnumerable<T> Unfold<T>(this T seed) {
I am writing code that will populate the Margin , Padding and BorderThickness properties
I'm writing code where I retrieve XML from a web api, then parse that
I am writing code that involved a for loop that makes calculations at each
I'm writing code that automatically generates HTML, and I want it to encode things
When writing code in Python, how can you write something next to it that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.