7/19/2016

double memcpy to byte, example. useful in serial communication

When we program the serial communication,
You may want to send double number in bytes, rather than strings.

In other words,
when we have 123123123123.123123123123 double value.
it is better send value to byte of sizeof(double), rather than the 25byte string.

The following example further, an example that sends a double 3 dogs as a byte.
...
double x = 1234.4567+10;
  double y = 2345.6789+10;
  double z = 3456.7891+10;

  char sendingStr[sizeof(double) * 3];

  memcpy(sendingStr, &x, sizeof(double));
  memcpy(sendingStr + sizeof(double), &y, sizeof(double));
  memcpy(sendingStr + sizeof(double) * 2, &z, sizeof(double));

  m_Comm.WriteComm((BYTE*)sendingStr, sizeof(double) * 3);
...


In addition, if there is the data to be send prefix is as follows.
...
double x = 1234.4567+10;
  double y = 2345.6789+10;
  double z = 3456.7891+10;

  char sendingStr[sizeof(double) * 3 + 2];
  sendingStr[0] = '_';
  sendingStr[1] = 'E';

  memcpy(sendingStr + 2, &x, sizeof(double));
  memcpy(sendingStr + 2 + sizeof(double), &y, sizeof(double));
  memcpy(sendingStr + 2 + sizeof(double) * 2, &z, sizeof(double));

  m_Comm.WriteComm((BYTE*)sendingStr, sizeof(double) * 3 + 2);
...

And so if you want to change the byte sent back to double is when you do the following:
...
double Mx, My, Mz;
   memcpy(&Mx, MxyzStr, sizeof(double));
   memcpy(&My, MxyzStr+sizeof(double), sizeof(double));
   memcpy(&Mz, MxyzStr + sizeof(double)*2, sizeof(double));
...

Creating a ghost usb boot

firstly, download this files, on here.

This link is my amazon drive. safe.

https://www.amazon.com/clouddrive/share/UsWjAZW1CWCnyIKsqSgzbXhyD10GdkQOTYoQNyNyBNv?ref_=cd_ph_share_link_copy


1)
HPUSBDisk.exe to install the files.
Run the installation file.

Unpack the compressed Bootingimg.zip.
and It sets the path where you extracted.

And click start button.

2)
autoexec.txt, and config.sys file to save your the usb.
(Autoexec.txt file is changed to the autoexec.bat file name.)

3)
After you extract the compressed GHOST.zip, stores with usb.

4)
Now the end if you set the boot order to boot to a usb!

5)
When the boot is called A:> ,  A:> ghost.exe  you can run the ghost.


opencv 3.0 trackbar simple example in video

simple example but good to understand

check..
What is the role of on_trackbar?
But function in Canny g_slider value, why use it?





< git hub - gist >

///

opencv 3.0 trackbar usage simple example

very very simple example
but easy to know the principle




< git-hub gist >

///