/* sprintf example */
// Write integers to a string.
#include <stdio.h>



int main ()
{
  char buffer[32];  ;
// This is what it looks like on the sending side.
// Here's a data example.
  int  n  ;
  unsigned Blue   ; 
  unsigned Green  ; 
  unsigned Red    ;
  unsigned NearIR ;
  unsigned Press  ;
  unsigned dP     ;
  unsigned V      ;
  float pressure  ;
  
  pressure=851.23456 ;
  

  Blue=1002; Green=100; Red=1022; NearIR=950; Press=850; dP=300; V=512;
  n=sprintf(buffer, "%04u%04u%04u%04u%04u%04u%04u", Blue,Green,Red,NearIR,Press,dP,V);
  n=sprintf(buffer, "Pressure=%04.3f",pressure) ;

// Replace this command with the send command.
  printf ("[%s] is a string %d chars long\n",buffer,n);
  
// This is what it looks like on the receiving side.
  unsigned BlueRead   ; 
  unsigned GreenRead  ; 
  unsigned RedRead    ;
  unsigned NearIRRead ;
  unsigned PressRead  ;
  unsigned dPRead     ;
  unsigned VRead      ;

  sscanf(buffer, "%4u%4u%4u%4u%4u%4u%4u", &BlueRead,&GreenRead,&RedRead,&NearIRRead,&PressRead,&dPRead,&VRead) ;
  
  printf("Blue on receving side = %4u counts \n",BlueRead) ; 
  printf("Green on receving side = %4u counts \n",GreenRead) ; 
  printf("Red on receving side = %4u counts \n",RedRead) ; 
  printf("NearIR on receving side = %4u counts \n",NearIRRead) ; 
  printf("Pressure on receving side = %4u counts \n",PressRead) ; 
  printf("dP on receving side = %4u counts \n",dPRead) ; 
  printf("Vsupply on receving side = %4u counts \n",VRead) ; 
  
  return 0;
}