구조체 및 배열 값 입력 질문드립니다

rider7979의 이미지

안녕하세요
아래와 같이 구조체에 값 입력하구요
구조체를 char 배열에 memcpy로 복사하여 전송하는 간단한 소스입니다
일단 확인해보니 USER_ID나 GPS에 엉뚱한 값이 들어가고 있네요
아주 단순하게 for문으로 값을 입력해준다고 생각하는데
뭐가 틀렸는지 아무리 봐도 모르겠습니다;;;;;
조언 부탁드립니다
아래 INT8U는 unsigned char 입니다

EMG_PACKET PACKET_Creation(void)
{
  EMG_PACKET emg_packet;
 
  emg_packet.Entire_Msg_Length = sizeof(emg_packet);
  INT8U user[13]={0,1,2,3,4,5,6,7,8,9,0};
 
  //TAG_ID[2];
  emg_packet.TAG_ID[0] = 0;
  emg_packet.TAG_ID[1] = 1;  
 
  //USER_ID[12];
  for(int cnt=0;cnt==11;cnt++){
    emg_packet.USER_ID[cnt+2] = user[cnt];
  }
  //GPS_Data[11];
  INT8U latitude[5];          INT8U longitude[5];
  latitude [0] = 35;          latitude [1] = 7;     latitude [2] = 3;           latitude [3] = 44;           latitude [4] = 'N';         
  longitude [0] = 128;        longitude [1] = 58;   longitude [2] = 4;          longitude [3] = 92;          longitude [4] = 'E';
 
  for(int cnt=0;cnt==4;cnt++){
    emg_packet.GPS_Data[cnt] = latitude[cnt];
  }
  for(int cnt=5;cnt==9;cnt++){
    emg_packet.GPS_Data[cnt] = longitude[cnt];
  }
  //Battery;
  emg_packet.Battery = 0x63;
  BSP_Debug_Put_String("PACKET_Creation\r\n");    
  return emg_packet;
}
 
bool Send_Packet(EMG_PACKET emg_packet)
{
  //bool send_flag = FALSE;
  INT8U data[sizeof(emg_packet)];
  memcpy(data, &emg_packet, sizeof(emg_packet));
//  int size=0;        
  BSP_WCDMA_SendCmd((INT8U*)data); 
 
  BSP_Debug_Put_String("Send_Packet\r\n");  
  return TRUE;
}
jick의 이미지

cnt==4 => cnt<4

rider7979의 이미지

다시 자세히 보니...실수한 부분이 많네요.....
해결 했습니다....
답변 주신분 감사합니다

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.