/************************************************************************* * iecasdu_create_type_36 *************************************************************************/ void iecasdu_create_type_36 (u_char *buf, size_t *buflen, int num, float *mv) { struct iec_type36 type; struct cp56time2a tm; u_short ioa = 1; const u_char ioa2 = 0; int i; size_t len; time_t_to_cp56time2a(&tm); // current_cp56time2a(&tm); // len = sizeof(u_short)+sizeof(u_char)+sizeof(struct iec_type36); for (i=0; i < num; i++, mv++, ioa++) { type.mv = *mv; type.ov = 0; type.res = 0; type.bl=0; type.sb=0; type.nt=0; type.iv=0; type.time = tm; // memcpy(buf + len*i, &ioa, sizeof(u_short)); // memcpy(buf + len*i + sizeof(u_short), &ioa2, sizeof(u_char)); // memcpy(buf + len*i + sizeof(u_short) + sizeof(u_char), &type,sizeof(struct iec_type36)); // *buflen += len; memcpy(buf, &type, sizeof(struct iec_type36)); *buflen += sizeof(struct iec_type36); } }
void current_cp56time2a (cp56time2a *tm) { time_t timet; timet = time(NULL); time_t_to_cp56time2a(tm,&timet); }
/************************************************************************* * iecasdu_create_type_103 *************************************************************************/ void iecasdu_create_type_103 (u_char *buf, size_t *buflen) { struct iec_type103 type; time_t_to_cp56time2a(&type.time); //current_cp56time2a(&type.time); //memcpy(buf, &ioa, sizeof(u_short)); //memcpy(buf + sizeof(u_short), &ioa2, sizeof(u_char)); //memcpy(buf + sizeof(u_short) + sizeof(u_char), &type, sizeof(struct iec_type103)); //*buflen += sizeof(u_short) + sizeof(u_char) + sizeof(struct iec_type103); memcpy(buf, &type, sizeof(struct iec_type103)); *buflen += sizeof(struct iec_type103); }