본문 바로가기

전체 글879

C ] isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, 함수 구현 int my_isalpha(int c) { return (c >= 'A' && c = 'a' && c = 'A' && C = 'a' && C = '0' && c = 'A' && c = 'a' && c = 0 && c = 32 && c = 0 && c 2023. 3. 25.
C언어 ] leetCode 1689 - Partitioning Into Minimum Number Of Deci-Binary Numbers A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not. Given a string n that represents a positive decimal integer, return the minimum number of positive deci-binary numbers needed so that they sum up to n. Example 1: Input: n = "32" Output: 3 Explanation: 10 + 11 + 11 = 32 Ex.. 2023. 3. 25.
CAN Bus Load 계산 Bus load = used capacity / Max capcity 로 계산된다. 먼저 worst case의 프레임 bit 수를 알아야하는데, 예를들어 11 bit identifier를 CAN frame을 예시로 계산해보자. Field Name Sub Field Length (bit) Start of Frame SOF 1 Arbitration Field Identifier 11 RTR 1 Control Field IDE 1 R0 1 DLC 4 Data Field D0-D8 8n CRC Field CRC 15 CRC Delimiter 1 Ack Field Ack 1 Ack Delimiter 1 End of Frame EOF 7 여기에다 추가해야 할 것이 있다. 프레임 사이의 intermission 3 b.. 2023. 3. 20.
메모리 인터페이스, SDRAM 인터페이스 메모리 인터페이스 일반적인 메모리의 핀 구성요소는 위의 사진과 같다. Address Pin과 Data Pin으로 구성되어 있고, 칩을 활성화하기 위한CS\(Chip Select 또는 CE)핀이 있고, OE(Output Enable) 신호 핀이 있다. OE는 읽기 동작에 대한 enable 신호이고, WE(Write Enable)핀이 따로 있는 경우도 있다. 만약 OE핀만 있다면 OE가 logic 1일땐 Read, OE가 0일땐 Write로 동작한다. 위 Flash Memory를 예시로 보면 Address Line은 A0~A18 19개가 있고, 양방향으로 쓰이는 Data Line은 DQ0~DQ15 16가 있다. Data Line이 16개라는 건 한번에 16bit(2Byte)를 읽을 수 있는 메모리라는 뜻이고.. 2023. 3. 20.
Fragmentation을 피하기 위한(안전한) UDP payload size HTML 삽입 미리보기할 수 없는 소스 TCP는 누락된 패킷 재전송과 패킷 재정렬 메커니즘이 있는 연결지향(stream-oriented) 프로토콜이기 때문에 단편화가 발생하는 경우 성능 저하가 발생할 순 있지만 단편화로 인한 직접적인 패킷 손실은 발생하지 않는다. 반면 UDP는 연결성이 없고(message-oriented) 안정성을 추구하지 않는 프로토콜로 재전송이나 재정렬 메커니즘이 없기 때문에 패킷이 손실되지 않도록 하려면 단편화를 피해야 한다. HTML 삽입 미리보기할 수 없는 소스 RFC 1122 문서 상 IPv4에서 reassemble 가능한 최소 MTU 권고값을 576 byte로 명시하고 있다. 실제로 네트워크상에 최소 규격만을 만족하는 장비가 있을 가능성을 배제할 수는 없고, 하나의 frag.. 2023. 3. 20.
애니데스크 승인없이 접속하기 암호 설정하면 승인 없이도 암호 입력 후 접속 가능 2023. 3. 19.
Lua 개발환경 구축하기 http://www.lua.org/ The Programming Language Lua www.lua.org 다운로드 압축해제 후 다운로드 폴더에서 다른 폴더로 옮기고 lua.exe 를 lua.exe 로 변경 환경변수 Path에 추가 Visual Studio Code 실행 후 Lua 와 Lua Debug extension 설치 Ctrl+F5 로 실행 2023. 3. 19.
DNS, 보조 DNS, DDNS, nslookup DNS DNS 는 'www.naver.com'과 같은 도메인 주소를 컴퓨터가 인식할 수 있는 '223.130.200.107' 과 같은 IP주소로 변환해주는 시스템이며 이 DNS를 운영하는 서버를 네임 서버라고 한다. 주 DNS가 있고 보조 DNS가 있는데, 통상적으로 주 DNS로 쿼리하다가 주 DNS에 문제가 생기면 그때 보조 DNS가 쿼리를 한다고 알려져 있지만 일부 장비에서는 주 DNS랑 보조 DNS는 의미없고 다 동시에 작동하는데 가장 빠르게 IP정보를 가져온 곳을 채택한다고 한다. DNS서버는 보통 공유기에 등록되어 있어 일반적으로 DHCP 주소를 할당 받을 때 자동으로 DNS 서버 주소도 같이 할당 받게 된다. 통신사별 DNS 서버 주소 기본 보조 KT olleh 168.126.63.1 168... 2023. 3. 19.
MDIO(Management Data Input/Output) MII MII(Media Independent Interface)는 100Mbit/s 이더넷에서의 상위 계층인 MAC에서 하위 계층인 PHY 간 표준 인터페이스이다. 4 bit 단위로 데이터를 송수신(TXD[3-0], RXD[3-0])하므로 100Mbit/s 처리량을 달성하기 위해 25MHz클럭이 필요하다. MII와 MDIO MII에는 두가지 인터페이스가 있다. 이더넷 프레임 데이터 송수신을 위한 데이터 인터페이스 PHY를 관리하기 위한 인터페이스인 MDIO. 작동전 PHY를 설정하고, 작동중에 Link Status를 모니터링하기 위해 PHY의 control, status 레지스터 등을 읽고 쓰기 위한 인터페이스이다. MDIO MDIO는 SMI(Serial Management Interface) 또는 M.. 2023. 3. 12.
TMS320F28388D ] phy 레지스터 읽어 link status 감지하기 lwiplib.c 파일에서 bmsr을검색하면 link status를 감지하는 방법을 알 수있다. 먼저 이더넷 initialization 를 하면 Ethernet_getHandle() 함수 안에서 phy 설정을 하고 있긴한데, 그렇게 그냥 써도 이더넷통신은 되지만 phy 칩을 직접 다루려면 바깥에서 올바른 설정값으로 다시 설정해줄 필요가 있다. #define EPHY_BMSR 0x00000001 // Ethernet PHY Basic Mode Status#define EPHY_BMSR_LINKSTAT 0x00000004 // Link Status//MDIO ConfigurationsEthernet_configureMDIO(Ethernet_device_struct.bas.. 2023. 3. 12.
헬리콥터의 Main Gearbox (MGB) In helicopters, power transfer function from the engine to Main Rotor, Tail Rotor and other necessary accessories is performed by the Main Gearbox, typically known as Transmission as well. The main purpose of a helicopter main gearbox or transmission is to reduce output rpm of the engine to most suitable level for driving the main rotors and tail rotors of a helicopter. For example, a helicopter.. 2023. 3. 10.
변수를 특정 메모리 영역(섹션 또는 주소)에 배치하기 [공개] 특정 영역에 배치하기 MEMORY { // ... CPU1TOCPU2RAM : origin = 0x03A000, length = 0x000800 CPU2TOCPU1RAM : origin = 0x03B000, length = 0x000800 // ... } SECTIONS { // ... MSGRAM_CPU1_TO_CPU2 : > CPU1TOCPU2RAM, type=NOINIT MSGRAM_CPU2_TO_CPU1 : > CPU2TOCPU1RAM, type=NOINIT // ... } #pragma DATA_SECTION(readData, "MSGRAM_CPU1_TO_CPU2") typedef struct { uint32_t u16; float f; } test_t; test_t readData; 특정 주소.. 2023. 2. 28.
PlatformIO 사용방법 VS Code extension에서 PlatformIO IDE 검색후 인스톨 인스톨 후 VS Code 재실행 왼쪽 PlatformIO 아이콘 클릭 후 PIO Home - Open New Project 프로젝트명과 보드, 프레임워크, 프로젝트 위치 설정 하단에 PIO Home, Build, Upload, Serial Monitor 등의 아이콘이 있다. 시리얼 모니터 보레이트 설정방법 디폴트는 9600이고 platformio.ini 파일에 다음과 같이 추가해 변경가능하다. 라이브러리 다운로드 방법 설정방법 PIO Home - Libraries - Search libraries - Add to Project 그러면 platformio.ini 파일에 library dependency(lib_deps =)가 추가.. 2023. 2. 27.
UML State Machine State 란? Represents a distinct satge of an object's lifecycle. Different scenarios that an applcation object life cycle pasees through. A state is denoted by a round-cornered rectangle with the name of the state written inside it. 예시. The door can be in one of three states: "Opened", "Closed" or "Locked". It can respond to the events "Open", "Close", "Lock" and "Unlock". Types of states in UML 1.. 2023. 2. 27.
C#, WinForms ] 계산기 구현 STATE에 따라 버튼 이벤트가 다르게 동작해야 하기 때문에 어떻게 할까 고민하다 아래 4가지로 정의해서 구현해봄 IDLE COMPLETE_FIRST_NUMBER OPERATOR_INSERTED COMPLETE_SECONDE_NUMBER 지금 C#문법 배우는 중이고 일단 돌아가는거 보자 하고 막 만들어서 컨트롤 이름도 안바꿈.. namespace cal { public partial class Form1 : Form { enum state_t { IDLE, COMPLETE_FIRST_NUMBER, OPERATOR_INSERTED, COMPLETE_SECOND_NUMBER } state_t currentState = state_t.COMPLETE_FIRST_NUMBER; public Form1() { In.. 2023. 2. 25.
C#, WinForms ] label의 너비를 초과하는 글자 자르기 Graphics 객체를 사용해 사이즈를 구하고, 레이블 너비를 초과한 경우 Substring 메서드 사용해서 마지막 글자 지워버림 Substring 첫번째 매개변수는 추출할 문자열의 시작 인덱스, 두번째 매개변수는 추출할 문자열의 길이임. 초과되지 않게 주의 Graphics g = this.label1.CreateGraphics(); SizeF textSize = g.MeasureString(this.label1.Text, this.label1.Font); if(this.label1.Width < textSize.Width) { this.label1.Text = this.label1.Text.Substring(0, this.label1.Text.Length - 1); } 2023. 2. 25.
C# ] decimal 과 double 의 차이 C#에서 실수를 저장할 수 있는 변수로 double과 decimal이 자주 사용됨. double은 부동소수점 방식을 이용하고, decimal은 고정소수점 방식을 이용함 - double은 64비트(8바이트)크기에, 약 15~16 자리의 유효숫자를 가진다. decimal에 비해 연산이 빠르기에 대부분의 경우 사용됨. - decimal은 128비트(16바이트)크기에 28~29 자리의 유효숫자를 가진다. 정밀한 계산이 필요한 금융, 세금, 과학 등의 분야에서 사용됨. double d = 1.1 + 2.2; // d = 3.3000000000000003 decimal m = 1.1M + 2.2M; // m = 3.3 double의 경우 비교연산을 사용하면 예상 결과 나오지 않는다. 이는 double 은 이진수로 .. 2023. 2. 25.
C#, WinForms ] MessageBox 속성 private void button2_Click(object sender, EventArgs e) { MessageBox.Show("Do you want to delete?", "DELETE", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); } 2023. 2. 25.
C#, WinForms ] textBox 크기에 맞춰서 Font Size 조절하기, resize the font to fit in the texBox Graphics g = textBox1.CreateGraphics(); SizeF textSize = g.MeasureString(textBox1.Text, textBox1.Font); float scale = Math.Min(textBox1.Width / textSize.Width, textBox1.Height / textSize.Height); float fontSize = textBox1.Font.Size * scale; textBox1.Font = new Font(textBox1.Font.FontFamily, fontSize, textBox1.Font.Style); textBox 컨트롤의 Graphics object를 구함 text와 font를 매개변수로 넣고 sizeF 구조체로 너비와 높이 구함.. 2023. 2. 25.
C#, WinForms ] 천 단위로 콤마 넣기, separate Numbers with commas string.Format("{0:#,##0}", num); 사용 예시. label의 textChanged Event처리 함수 "."으로 끝나는지, 소숫점을 포함하는지, 정수인지 구분하여 처리. string의 Replace()와 Split() 메서드 사용 if(this.label1.Text.EndsWith(".")) { string numStr = this.label1.Text.Replace(",", "").Replace(".", ""); if (decimal.TryParse(numStr, out decimal num)) { string formattedStr = string.Format("{0:#,##0}", num); this.label1.Text = formattedStr + "."; } } else.. 2023. 2. 25.
C#, WinForms ] 정수인지 실수인지 확인하기, Integer / Real number 구분 Math.Floor() 함수를 사용하면된다. 내림한게 원래 값과 같으면 정수, 아니면 실수이다. double result = first + second; if(Math.Floor(result) == result) { this.label1.Text = string.Format("{0:#,##0}", result); } else { this.label1.Text = string.Format("{0:#,##0.########################}", result); } 2023. 2. 25.
C# ] 문자 또는 문자열 집합 중 하나라도 포함하고 있는지 확인하기 Contains 또는 IndexOfAny 사용 가능 Contains() 는 특정 문자열 또는 문자열 배열중 하나가 문자열 내에 존재하는 존재하는지 여부를 검사하여 bool을 반환. string str = "Hello, World!"; string[] keywords = {"World", "Universe"}; if (str.Contains(keywords[0])) { Console.WriteLine("The string contains the keyword: " + keywords[0]); } if (!str.Contains(keywords[1])) { Console.WriteLine("The string does not contain the keyword: " + keywords[1]); } Index.. 2023. 2. 25.
C#, WinForms ] 버튼 속성. 테두리색 및 굵기, 클릭시 배경색 변경하기 FlatStyle - Flat 설정 FlatAppearance - BorderColor 로 테두리색 변경 FlatAppearance - BorderSize 로 테두리 굵기 변경. 0으로 하면 테두리 없앰 FlatAppearance - MouseDownBackColor 로 클릭시 버튼 배경색 변경 FlatAppearance - MouseOverBackColor 로 마우스가 올라왔을 때 배경색 변경 2023. 2. 25.
Interrupt Nesting & SW Priorization [공개] 관련문서 https://software-dl.ti.com/C2000/docs/c28x_interrupt_nesting/html/index.html C28x Interrupt Nesting In most cases a system will only require one or two interrupts to be nested. This is easily handled by the example shown previously. There is, however, an example provided by which covers possibilities for every single interrupt in the group. This example software-dl.ti.com PIE 그룹과 채널 디폴트 우선순.. 2023. 2. 25.
CANFD (MCAN) [공개] 메시지램 통해 CPU1에서 사용가능 CPU2에선 불가. MCAN이 사용하는 메시지램은 CPU1_TO_CM, CM_TO_CPU1 MSGRAM 과는 별개 송신 수신 FIFO사용해 수신시 Loss 없음 2023. 2. 25.
EMIF로 SDRAM 사용 [공개] EMIF(External Memory Interface)는 어플리케이션이 on-chip 메모리보다 더 많은 memory storage를 필요로 할 때, Flash나 SDRAM 같은 외부메모리에 access 할 수 있도록 인터페이스 수단을 제공한다. SDRAM은 CS0(Chip Select)사용하고 링커커맨드 파일을 확인하면 CS0은 시작주소 0x80000000 부터 씀 데이터시트 분석 후 파라미터 설정하고 테스트 128MB SDRAM이 마지막 주소 0x83FFFFFF 까지 잘 써진것을 확인 memcpy_fast_far(), memcpy() 함수 사용 가능. 일반 참조연산으로 대입하고 확인해봐도 됨 Recommended Use of Far Memory https://www.ti.com/lit/an/spra.. 2023. 2. 25.
CAN [공개] Bit Timing 계산 : http://www.bittiming.can-wiki.info/ CAN Bit Time Calculation The following calculation sheet is mostly useful for classic CAN as defined in ISO-11898 before 2015. For the new CAN FD as defined in ISO-11898:2015 work is in Progress. CiA provides the document CiA 601-3 CAN FD bit-timing recommendations. By providing t www.bittiming.can-wiki.info Receive/Transmit Priority, Frame Ide.. 2023. 2. 25.
lwIP UDP 예제 [공개] CPU1 예제 위치 CM 예제위치 sys_check_timeouts() : LwIP function is called to handle certain LwIP internal periodic tasks (protocol timers, retransmission of TCP packets...). 2023. 2. 25.
배치파일 관리자 권한으로 실행되게끔 하기 원본 배치파일의 바로가기를 만든다. 바로가기 파일 우클릭 - 속성 - 고급 관리자 권한으로 실행 체크 후 확인 이러고 원본은 숨겨두면 된다. 혹은 bat to exe converter를 사용하는 방법도 있다. 2023. 2. 22.
C#, WinForms ] OpenFileDialog, 이미지 pictureBox에 로드하기 private void button1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Image Files (*.bmp;*.jpg;*.jpeg;*.png)|*.BMP;*.JPG;*.JPEG,*.PNG"; dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); if(dialog.ShowDialog() == DialogResult.OK) { textBox1.Text = dialog.FileName; pictureBox1.SizeMode = PictureBoxSizeMode.S.. 2023. 2. 22.