�# include <stdio.h>���$�int nims_expand_hrs(work,ibkg,idata)O�/******************************************************************************�O�*_Title NIMS_EXPAND_HRS Expand NIMS HRS (background & data) into 16-bit words���@�*_Args Type Variable I/O Description */I� unsigned char work[90]; /* !I Buffer of 72 10-bit data items*/�I� unsigned short int ibkg[4]; /* !O Buffer of 4 background items */�I� unsigned short int idata[68]; /* !O Buffer of 17*4 sensor items */��/*J�*_Descr Expand NIMS HRS background and sensor data from packed 10-bit formB�* to 16-bit signed integers: 4 background items and 17*4=68 sensorD�* items. Each contiguous 5-byte segment containing 4 10-bit numbers"�* is expanded to 4 16-bit numbers.��-�*_Calls NIMS_EXPAND4 (not generally portable)����*_Keys NIMS, STRING��F�*_Hist 16feb90 R Mehlman UCLA/IGPP Original Version (VAX/VMS Fortran)G�* 26may92 RMX Fixed incorrect WORK dimension: (18.5) should have been�9�* (5,18) but didn't actually matter. Made it WORK(90).�I�* 02nov92 RMX Renamed from HRS_EXPAND. NIMEXP changed to NIMS_EXPAND4.�C�* 28feb93 RMX Portable C version (calls C or Assembler version of�3�* NIMS_EXPAND4, which is not generally portable)��*_End�P�*******************************************************************************/� {�A� unsigned char *ip; /* Address of current 5-byte input set */�F� unsigned short int *jp; /* Address of current 4-word output set */.� long k; /* Index of 4-word output set */��=� nims_expand4(work, ibkg); /* Expand 4 background items */���<� ip = work+5; /* Point to start of input sensor items */7� jp = idata; /* Point to start of output buffer */�G� for (k = 0; k < 17; k++) { /* Loop on 17 sets of 4 sensor items */�-� nims_expand4(ip, jp); /* Expand set */�2� ip = ip + 5; /* Increment input pointer */3� jp = jp + 4; /* Increment output pointer */�9� } /* End loop on 17 sets of 4 sensor items */�� return (0);�� }�P�/*******************************************************************************P�* In SunOS systems, the fortran compiler will insert an underscore character (_)J�* at the end of all subroutine names. The code enclosed by the "ifdef sun"?�* preprocesser statement will fortran routines to also call the��* nims_expand routine.P�*******************************************************************************/ �#ifdef sun�int nims_expand_hrs_(ibuf,obuf)�I� unsigned char work[90]; /* !I Buffer of 72 10-bit data items*/�I� unsigned short int ibkg[4]; /* !O Buffer of 4 background items */�I� unsigned short int idata[68]; /* !O Buffer of 17*4 sensor items */��{�$� nims_expand_hrs(work,ibkg,idata); � return(0);��}��#endif�# include <stdio.h>����int nims_expand4(ibuf,obuf)�O�/******************************************************************************�E�* The definition of these sub-scripts takes care of the byte swapping��* required on VAX systems.O�******************************************************************************/� �#ifdef vax�#define SCP1 0�#define SCP2 1�#else��#define SCP1 1�#define SCP2 0�#endifP�/*******************************************************************************E�*_Title NIMS_EXPAND4 Expand NIMS data: 5-byte input to 4 INT*2 words���A�*_Args Type Variable I/O Description */�I� unsigned char ibuf[5]; /* !I Input buffer of 4 10-bit items */�I� unsigned short int obuf[4]; /* !O Output buffer of 4 16-bit items */��/*G�*_Desc Expand 5-byte data or background segment of NIMS HRS packet from�D�* Galileo/NIMS EDR: 4 10-bit items into 4 16-bit (INTEGER*2) items.���*_Lims VAX-specific version���*_Keys NIMS, STRING���C�*_Hist 17oct83 R. Mehlman UCLA/IGPP ORIGINAL VAX ASSEMBLER VERSION��* Used by NIMS SE programs.�9�* Recoded for VAX from WDS PDP-11 XPND rtne in DESE.MAC�8�* 16feb90 RMX NIMS EDR processing version: documented$�* 02nov92 RMX Renamed from NIMEXP.6�* 26feb93 RMX VAX C version (not generally portable)@�* 18mar93 EME Make routine compatible with SunOS systems�*_End�O�******************************************************************************/�� {�'� unsigned short int mask10 = 0x03ff;� � union�� {�� unsigned char work1[4][2];�� unsigned short int work2[4];� � } work;���"� work.work1[0][SCP1] = ibuf[1];"� work.work1[0][SCP2] = ibuf[0];,� obuf[0] = (work.work2[0] >> 6) & mask10;��"� work.work1[1][SCP1] = ibuf[2];"� work.work1[1][SCP2] = ibuf[1];,� obuf[1] = (work.work2[1] >> 4) & mask10;��"� work.work1[2][SCP1] = ibuf[3];"� work.work1[2][SCP2] = ibuf[2];,� obuf[2] = (work.work2[2] >> 2) & mask10;��"� work.work1[3][SCP1] = ibuf[4];"� work.work1[3][SCP2] = ibuf[3];%� obuf[3] = work.work2[3] & mask10;���� return (0);�� }���P�/*******************************************************************************P�* In SunOS systems, the fortran compiler will insert an underscore character (_)J�* at the end of all subroutine names. The code enclosed by the "ifdef sun"?�* preprocesser statement will fortran routines to also call the��* nims_expand routine.P�*******************************************************************************/ �#ifdef sun�int nims_expand4_(ibuf,obuf)K� unsigned char ibuf[5]; /* !I Input buffer of 4 10-bit items */�K� unsigned short int obuf[4]; /* !O Output buffer of 4 16-bit items */��{�� nims_expand4(ibuf,obuf);� � return(0);��}��#endif