Click here to Skip to main content
15,900,450 members

Comments by Member 15034232 (Top 5 by date)

Member 15034232 22-Apr-21 2:34am View    
I've already solved it.

Member 15034232 21-Apr-21 20:38pm View    
comment is just code line name.
This code is a code that receives DATA from an HR/SPO2 measuring machine called BPM-770.

I am connecting through UDP and I have to keep loading the machine's data like the console screen.
Member 15034232 20-Apr-21 4:11am View    
thx i try this :)
Member 15034232 20-Apr-21 4:10am View    
Deleted
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;


namespace bionics_udp_test_001
{
class Program
{

//----------------------------------------------
//
// 2021-04-20 수정 ver. (Hex 변환 추가)
// 1. 데이터를 계속 받아오기 위해 while 루프
// 2. 데이터 Hex 확인을 위해 Hex 변환
// 3. 현재 데이터 문제는 없이 돌아감.
//
//----------------------------------------------




static void Main(string[] args)
{


// (1) UdpClient 객체 성성
UdpClient cli = new UdpClient();

//장비와 연결부분

/* 바이오닉스 장비와 연결하기 위해서는 초기 Who? 통신 패킷에 대응하는 bionics 데이터가아닌
Broad 값을 입력시켜줘야 장비가 인식합니다. */

// string --> byte[]

string msg = "Broad";
byte[] datagram = Encoding.UTF8.GetBytes(msg);



// (2) Broad를 전송 시켜 바이오닉스 장비와 연결
cli.Send(datagram, datagram.Length, "192.168.1.100", 19000);
Console.WriteLine("[Send] 192.168.1.100 로 {0} 바이트 전송\n", datagram.Length);
Console.WriteLine("[Send] {0}", Encoding.UTF8.GetString(datagram));


//장비에서 데이터 불러오는 부분



// (3) 데이터 수신 (바이오닉스 장비에서 보내어오는 데이터 수신 - 수신 명령이 계속 돌아가야함.
while (true)
{
//IP 종단점 지정
IPEndPoint epRemote = new IPEndPoint(IPAddress.Any, 0);
byte[] bytes = cli.Receive(ref epRemote);

//수신 데이터 크기 출력 (안보여줘도 상관은 없을듯)
Console.WriteLine("\n[Receive] {0} 로부터 {1} 바이트 수신\n", epRemote.ToString(), bytes.Length);

//데이터 Hex 변환을 위한 임시 저장.
string hex = Encoding.UTF8.GetString(bytes);

//HEX 값 변환
string str = hex;
char[] charValues = str.ToCharArray();
string hexOutput = " ";

foreach (char _eachChar in charValues)
{
// Get the integral value of the character.
int value = Convert.ToInt32(_eachChar);
// Convert the decimal value to a hexadecimal value in string form.
hexOutput += String.Format("{0:X1} ", value);
// to make output as your eg
// hexOutput +=" "+ String.Format("{0:X}", value);

}

//Hex 값 출력
Console.WriteLine(hexOutput+"\r\n");
Console.WriteLine("----------------------------------------------------------------------------------------------------------------------");
}
// (4) UdpClient 객체 닫기
// cli.Close();

// 콘솔 값 확인을 위해 enter key 눌러서 줄 읽기. (안써도 됨)
Console.ReadLine();


}
}
}


sry my bad c#.

now i'm just study one weak c#.
this code is my first c# project code.

i just try button1 -> loop receive data :(
Member 15034232 20-Apr-21 2:15am View    
i found device login key thx