c#이나 .net framework을 쓰면 간편한데

win32로는 영 복잡할수 밖에 없는 듯?


그런데 QueryDosDevice()를 쓰면 0ms 라는데

  1. CreateFile("COM" + 1->255) as suggested by Wael Dalloul
    ✔ Found com0com ports, took 234ms.

  2. QueryDosDevice()
    ✔ Found com0com ports, took 0ms.

  3. GetDefaultCommConfig("COM" + 1->255)
    ✔ Found com0com ports, took 235ms.

  4. "SetupAPI1" using calls to SETUPAPI.DLL
    ✔ Found com0com ports, also reported "friendly names", took 15ms.

  5. "SetupAPI2" using calls to SETUPAPI.DLL
    ✘ Did not find com0com ports, reported "friendly names", took 32ms.

  6. EnumPorts()
    ✘ Reported some non-COM ports, did not find com0com ports, took 15ms.

  7. Using WMI calls
    ✔ Found com0com ports, also reported "friendly names", took 47ms.

  8. COM Database using calls to MSPORTS.DLL
    ✔/✘ Reported some non-COM ports, found com0com ports, took 16ms.

  9. Iterate over registry key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
    ✔ Found com0com ports, took 0ms. This is apparently what SysInternals PortMon uses.

[링크 : http://stackoverflow.com/.../how-do-i-get-a-list-of-available-serial-ports-in-win32]


m_MyPort 변수만 다른걸로 바꿔써주면 잘 작동 하는 듯

단, unicode 기반에서는 (LPSTR)대신 (LPWSTR)로 해주어야 에러가 나지 않는다.

void SelectComPort() //added function to find the present serial 
{

    TCHAR lpTargetPath[5000]; // buffer to store the path of the COMPORTS
    DWORD test;
    bool gotPort=0; // in case the port is not found

    for(int i=0; i<255; i++) // checking ports from COM0 to COM255
    {
        CString str;
        str.Format(_T("%d"),i);
        CString ComName=CString("COM") + CString(str); // converting to COM0, COM1, COM2

        test = QueryDosDevice(ComName, (LPSTR)lpTargetPath, 5000);

            // Test the return value and error if any
        if(test!=0) //QueryDosDevice returns zero if it didn't find an object
        {
            m_MyPort.AddString((CString)ComName); // add to the ComboBox
            gotPort=1; // found port
        }

        if(::GetLastError()==ERROR_INSUFFICIENT_BUFFER)
        {
            lpTargetPath[10000]; // in case the buffer got filled, increase size of the buffer.
            continue;
        }

    }

    if(!gotPort) // if not port
    m_MyPort.AddString((CString)"No Active Ports Found"); // to display error message incase no ports found

}


[링크 : http://stackoverflow.com/.../what-is-proper-way-to-detect-all-available-serial-ports-on-windows]

Posted by 구차니
프로그램 사용/gcc2017. 4. 4. 21:00

GCC G++ 공식문서를 찾지 못했는데

아무튼.. wchar_t 로 wide character형이 추가된것 외에는 차이가 없는듯

kldp 쪽을 봐도 gcc에서는 UTF-32 4byte 로 된다는 정도만 있는것 봐서는

MSVC에 비해 유니코드 대응이 미진하긴 미진 한 듯.


wchar_t

type for wide character representation (see wide strings). Required to be large enough to represent any supported character code point (32 bits on systems that support Unicode. A notable exception is Windows, where wchar_t is 16 bits and holds UTF-16 code units) It has the same size, signedness, and alignment as one of the integral types, but is a distinct type.


[링크 : http://en.cppreference.com/w/cpp/language/types]

[링크 : http://en.cppreference.com/w/cpp/keyword]

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc variadic macro  (0) 2017.06.20
문자열에 escape 로 특수문자 넣기  (0) 2017.06.19
gcc 매크로 확장 define stringfication  (0) 2017.01.02
gcc make CFLAGS=-D 관련  (0) 2016.11.17
gcc -fPIC  (0) 2016.06.22
Posted by 구차니
Programming/C Win32 MFC2017. 4. 4. 20:41

음.. CString에서 제공하는 메소드는 아래뿐이네.. GetData() 나 다른것들은 상속에 의해서 다른 클래스에서 온 듯

operator LPCTSTR

GetBuffer() 

[링크 : https://msdn.microsoft.com/en-us/library/aa315043(v=vs.60).aspx]


GetString()은 누구꺼냐.. CObject의 스멜이 나긴 한다만...

(LPCTSTR)로 캐스팅하는 것과 거의 구현이 같은 GetString() 이란 메소드도 있습니다. 

[링크 : https://indidev.net/forum/viewtopic.php?f=5&t=92]


음.. 걍 void* 형으로 캐스팅?

CString str = L"английский"; //Russian Language

DWORD dwWritten=0;

WriteFile(pHandle , (void*) str, str.GetLength()*sizeof(TCHAR),&dwWritten , NULL);

[링크 : https://social.msdn.microsoft.com/.../how-to-send-unicode-characters-to-serial-port?forum=vcgeneral]


LPSTR - Long Pointer STRing

LPCSTR - LP Const STRing

LPTSTR - LP Tchar STRing

LPCTSTR - LPC Tchar STRing

LPWSTR - LP Wchar STRing

LPCWSTR - LP Const Wchar STRing

[링크 : http://pelican7.egloos.com/v/1768951]


char 형식의 좁은 문자 리터럴(예: 'a')

wchar_t 형식의 와이드 문자 리터럴(예: L'a')

char16_t 형식의 와이드 문자 리터럴(예: u'a')

char32_t 형식의 와이드 문자 리터럴(예: U'a') 

[링크 : https://msdn.microsoft.com/ko-kr/library/69ze775t.aspx]


TEXT("")과 _T("")의 차이점은

TEXT("")는 WinNT.h에서 #define했고

_T("")는 tchar.h에서 TEXT가 4글자라서 _T이렇게 2글자로 #define했다. 

[링크 : http://x108zero.blogspot.kr/2013/12/text-t-l.html]



+

tchar.h

#define __T(x)      L ## x

#define _T(x)       __T(x)


음.. L 이야 Long에 대한 prefix literal 이니...까?



'Programming > C Win32 MFC' 카테고리의 다른 글

mfc ccombobox 문자열 받아오기  (0) 2017.04.05
MFC 라디오버튼 사용하기  (0) 2017.04.05
bit field와 컴파일러별 byte align  (0) 2017.03.27
MFC CButton 마우스 클릭시 작동하기  (0) 2017.03.08
GetHttpConnection()  (0) 2017.03.03
Posted by 구차니

시리얼포트 10번 이후 열기라는 글이 있어서 보니


버그가 있어서 COM9 까진 그냥 여는데, 그 이후에는

\\.\COM%d 식으로 표현을 해야 하는데 escape 문자를 넣어주어야 하니 이렇게 미친듯이 길어진다.


hPort = CreateFile("\\\\.\\COM10", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); 

[링크 : http://stackoverflow.com/questions/11775185/open-a-com-port-in-c-with-number-higher-that-9]

Posted by 구차니

심심해서 계산을 해보니


많이 차이나는데?


소주 360ml 20~16.5도 59.4ml~72ml(알콜함량)

병맥 500ml 4.5도 22.5ml(알콜함량)


알콜양으로도 맥주 두병은 먹어야 소주 한병 될까 말까네?



아.. 큐팩은

1800ml 4.5도 81ml 이니까 소주보다 많아지는군 ㅋ

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

연휴 끝  (0) 2017.05.07
망할 실손보험 !!!  (0) 2017.04.11
대한통운 택배 스미싱?  (0) 2017.03.27
AMD 라이젠(zen) 프로세서 발표  (0) 2017.03.05
환공어묵  (0) 2017.02.23
Posted by 구차니
embeded/Cortex-M3 Ti2017. 4. 4. 11:41

이걸 샀는데 헉.. 2.54mm 간격이 아니네?!?!

아무튼.. 얘는 Serial Wire Debugger라.. JTAG 핀을 제공하지 않는다.

[링크 : http://www.devicemart.co.kr/1320869]


그림판으로 장난질.

SWD는 SWC SWD SWO 세개 이고

JTAG은 TCK TMS TDI TDO 인데

TDI를 제외한 3개의 핀은 연결이 가능한 듯 하다


데이터시트상 핀 배열은 이런데.. 

핀설명은 아래와 같음

+

[링크 : http://forum.falinux.com/zbxe/?document_srl=796669...readed_count]


+

실험을 해보니 다 필요 없고..

최소사양(?)인 SWCLK +SWDIO(I/O) 딱 두줄이면 끝..

지금까지 JTAG으로 쓴 줄 알았는데 SWD로 쓰고 있었다는거에 한번 더 깜놀..

'embeded > Cortex-M3 Ti' 카테고리의 다른 글

keil sct - 링커 스크립트  (0) 2017.12.11
lm3s 부트로더  (0) 2017.11.21
어? 의외로 RX busy는 없네?  (0) 2017.03.27
lm3s1607 uart pull up 문제  (0) 2017.03.24
ti cortex-m3 driverlib - UARTConfigSetExpClk()  (0) 2017.03.23
Posted by 구차니

그런데 미세먼지 쩖

먹어서 응원하자?!


일회용 마스크로는 어림도 없어 보이고

조만간 스포츠 마스크 하나 사야 할 듯 ㅠㅠ


그나저나.. 평속 20km도 안되네 ㅋㅋㅋ

어느 세월에 예전 25km 수준을 복구하려나 ㅠㅠ


Posted by 구차니

EF / EF-S는 플랜지 는 같고

EF-M은 짧다?


Canon's EF-M has an 18mm flange focal distance, compared to 44mm for the EF and EF-S systems. 

[링크 : http://photo.stackexchange.com/questions/27254/whats-the-difference-between-canon-ef-s-and-ef-m]



+

The flange focal distance is 17.526 millimetres (0.6900 in) for a C mount.

CS-mount has a flange focal distance of 12.50 millimetres (0.492 in)

[링크 : https://en.wikipedia.org/wiki/C_mount]


Its large diameter and relatively short flange focal distance of 44.0 mm allows mechanical adaptation of EF camera bodies to many types of non-EF lenses.

[링크 : https://en.wikipedia.org/wiki/Canon_EF_lens_mount]


M42 lens mount Flange 45.5 mm

[링크 : https://en.wikipedia.org/wiki/M42_lens_mount]


마운트 종류 엄청 많네 -_-?

[링크 : https://en.wikipedia.org/wiki/Lens_mount#List_of_lens_mounts]

'이론 관련 > 사진 광학 관련' 카테고리의 다른 글

열영상 이미지 - 컬러  (0) 2017.08.24
ir corrected lens ld low dispersion  (0) 2017.07.04
이미지 센서 - ccd cmos 비교  (0) 2016.09.22
크롭바디 EF / EF-S 렌즈 화각 테스트  (0) 2016.08.29
back focus  (0) 2016.07.22
Posted by 구차니

망할(!) 유니코드 ㅠㅠ

sqlite의 내용이 utf-8일텐데 아무튼.. 이걸 받아서 print 하니

죄다 u'\u' 이런식으로 유니코드 문자열을 알려주는 접두와 16진수로만 출력이 된다

그래서 이걸 정상적으로 출력하는걸 찾아보는데

간편하게 출력하는건 없고.. 파이썬 print 함수의 특징으로 봐야 하려나?


튜플,리스트 단위로 출력하면 escape 된 채로

항목 하나만 출력하면 정상적으로 한글로 나온다.

도대체 머야?!


아무튼 아래와 같이 하면 정상출력되긴 한다.( u' ' 접두는 붙는다.)

print repr(a).decode("unicode-escape") 

[링크 : http://stackoverflow.com/.../python-print-unicode-strings-in-arrays-as-characters-not-code-points]

'Programming > python(파이썬)' 카테고리의 다른 글

python + openCV 공부 시작  (0) 2019.04.30
pypy  (0) 2018.04.04
파이썬 리스트(list)와 튜플(tuple)  (0) 2017.04.02
파이썬 type 확인하기  (0) 2017.04.02
python sqlite3  (0) 2017.03.30
Posted by 구차니

튜플은 (1,2,3) 식으로 출력되고

리스트는 [1,2,3] 식으로 출력된다.


다만 내용적으로는 리스트는 순서가 변할수 있으며(순서가 의미가 없다)

튜플은 순서를 바꿀수 없다(즉, 순서에 의미가 있다)


4.6.5. Tuples

Tuples are immutable sequences, typically used to store collections of heterogeneous data (such as the 2-tuples produced by the enumerate() built-in). Tuples are also used for cases where an immutable sequence of homogeneous data is needed (such as allowing storage in a set or dict instance). 

[링크 : https://docs.python.org/3/library/stdtypes.html#tuples]


4.6.4. Lists

Lists are mutable sequences, typically used to store collections of homogeneous items (where the precise degree of similarity will vary by application). 

[링크 : https://docs.python.org/3/library/stdtypes.html#lists]

'Programming > python(파이썬)' 카테고리의 다른 글

pypy  (0) 2018.04.04
파이썬 print가 희한하네..  (0) 2017.04.02
파이썬 type 확인하기  (0) 2017.04.02
python sqlite3  (0) 2017.03.30
python smtplib의 신비..?  (0) 2016.12.30
Posted by 구차니