You must include your library directory in your sources; For that add path to
your project folder: Project -> Properties -> Configuration Properies
-> General -> VC++ Directories -> Include Directories and
Library Directories;
Tuesday, November 21, 2017
Visual Studio 2012 error MSB8020: The builds tools for v120 (Platform Toolset = 'v120') cannot be found
right-click on project name -> properties -> configuration
properties -> general -> platform toolset -> Visual Studio 2012
(v110)
Other option is download and setup Microsoft Build Tools 2013 from http://www.microsoft.com/en-US/download/details.aspx?id=40760
Other option is download and setup Microsoft Build Tools 2013 from http://www.microsoft.com/en-US/download/details.aspx?id=40760
Thursday, November 9, 2017
Camera Link Camera Configuration over Frame Grabber Camera Link Serial Port
Camera Configuration within Camera Link is based on a simple asynchronous serial reading and writing of configuration data. Within the Camera Link standard specification, a serial communication interface is defined. This standardized serial interface is available on the frame grabber. It enables the interaction of a vendor specific camera configuration tool and the frame grabber specific implementation of the serial communication functionality.
In simple words: Any Camera Link compliant camera configuration software runs in combination with any Camera Link frame grabber. In this project we use Bitflow Karbon-CL Frame Grabber.
CLComm - An interface to the Camera Link serial port library.
This wraps both the standard CLAllSerial.h interface, and the BFSerial.h library, which provides various useful extensions to the core library.
To access Camera Link Serial Port cameras require a DLL file, which is supplied by the frame grabber manufacturer, to be installed on the PC. To verify this, use the PC’s registry editor (regedit) to confirm the following setting:
HKEY_LOCAL_MACHINE->SOFTWARE-> “CLSERIALPATH”.
Then, check the folder specified in the “Data” field of “CLSERIALPATH”, and verify that the folder contains a “clser***.dll” file.
Note: the file name of the DLL file is clser***.dll. “***” is up to the frame grabber manufacturer. If the DLL file does not exist there, place the DLL file into the folder. The DLL file is supplied by the frame grabber manufacturer.
Add a "CLAllSerial.NET.dll" reference to the target project, right click the project, choose "Add References" then from the "Projects" tab, choose "CLAllSerial.NET.dll" from your working directory.
To list available port using ComboBox DropDown list:
To list available baudrate ComboBox DropDown list:
Initialize the port:
Serial Receive Thread Function:
Close the Port for reading thread:
In order to use CLComm Component in the project, first add a reference to it, make sure to place the file "CLAllSerial.NET.dll" into your working directory, and set the target framework to ".NET Framework 4.5". The component "CLAllSerial.NET.dll" has compiled using ".NET Framework 4.5" so the target project must also use ".NET Framework 4.5".
Add a "CLAllSerial.NET.dll" reference to the target project, right click the project, choose "Add References" then from the "Projects" tab, choose "CLAllSerial.NET.dll" from your working directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CLComm; | |
// private member | |
private CLAllSerial m_clserial; | |
// Initialize the first Bitflow, Inc. CLSerial Interface. | |
m_clserial = new CLAllSerial(); | |
if (0 == CLAllSerial.GetNumPorts()) | |
{ | |
MessageBox.Show("The system has no CLSerial ports! Aborting.", "SimpleCom Initialization Error"); | |
Close(); | |
Application.Exit(); | |
} |
If you got this error message while debugging : " Could not load file or assembly 'ManagedBid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92d16d74ab2a6c4b' or one of its dependencies. An attempt was made to load a program with an incorrect format. " , check your "target framework" setting on your property, change to ".NET Framework 4.5".
To list available port using ComboBox DropDown list:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
serialPortDropDown.Items.Clear(); | |
uint numPorts = CLAllSerial.GetNumPorts(); | |
for (uint i = 0; i < numPorts; i++) | |
{ | |
string manufacturer = "", portID = ""; | |
uint version = 0; | |
CLAllSerial.GetPortInfo(i, ref manufacturer, ref portID, ref version); | |
string ItemObject = "(" + i + ") " + manufacturer + ", " + portID; | |
serialPortDropDown.Items.Add(ItemObject); | |
} |
To list available baudrate ComboBox DropDown list:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
baudRateDropDown.Items.Clear(); | |
// Add all supported baud rates to the combo box list. | |
CLAllSerial.BaudRates rates = m_clserial.GetSupportedBaudRates(); | |
string currentRate; | |
// Determine the current baud rate (just set it, if we aren't a BF port). | |
if (m_clserial.PortIsBF) | |
currentRate = m_clserial.BFGetBaudRate().ToString(); | |
else | |
{ | |
m_clserial.SetBaudRate(CLAllSerial.BaudRates.CL_BAUDRATE_9600); | |
currentRate = CLAllSerial.BaudRates.CL_BAUDRATE_9600.ToString(); | |
} | |
foreach (string rate in rates.ToString().Split(',')) | |
{ | |
string ItemObject = rate.Trim("CL_BAUDRTE ".ToArray()); | |
baudRateDropDown.Items.Add(ItemObject); | |
} | |
baudRateDropDown.Text = currentRate.Trim("CL_BAUDRTE ".ToArray()); |
Initialize the port:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
// Stop the data receive thread. | |
readThreadStop(); | |
// Close the opened serial port. | |
m_clserial.SerialClose(); | |
// Attempt to open the designated port. | |
m_clserial.SerialInit(index); | |
string manufacturer = "", portID = ""; | |
uint version = 0; | |
CLAllSerial.GetPortInfo(index, ref manufacturer, ref portID, ref version); | |
// Set the GUI as necessary. | |
serialPortDropDown.Text = manufacturer + ", " + portID; | |
populateBaudRateDropDown(); | |
// Restart the data receive thread. | |
m_readThread = new Thread(new ThreadStart(serialReadThreadFunc)); | |
m_readThreadContinue = true; | |
m_readThread.Start(); | |
} | |
catch (ApplicationException err) | |
{ | |
MessageBox.Show("Serial port initialization failed: " + err.Message, "CLSerial Initialization Error"); | |
Close(); | |
Application.Exit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// The serial read thread function. | |
/// </summary> | |
private void serialReadThreadFunc() | |
{ | |
try | |
{ | |
if (m_clserial.PortIsBF) | |
{ | |
// This is a BF port, so prefer the BFSerialRead method. | |
try | |
{ | |
while (m_readThreadContinue) | |
comListAppend(m_clserial.BFSerialRead(1024)); | |
} | |
catch (OperationCanceledException) | |
{ } | |
} | |
else | |
{ | |
// For non-BF ports, use the conventional SerialRead method. | |
while (m_readThreadContinue) | |
{ | |
uint readLen = m_clserial.GetNumBytesAvail(); | |
if (0 < readLen) | |
comListAppend(m_clserial.SerialRead(readLen, 100)); | |
Thread.Sleep(0); | |
} | |
} | |
} | |
catch (ApplicationException err) | |
{ | |
MessageBox.Show("Caught an exception: " + err.Message + "\n\nAborting the read thread. Data can still be written, but no data will be received.", "Data Read Thread Error"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Stop execution of the serial read thread. This method blocks until the read thread is halted. | |
/// </summary> | |
private void readThreadStop() | |
{ | |
if (null == m_readThread) | |
return; | |
do | |
{ | |
m_readThreadContinue = false; | |
if (m_clserial.PortIsBF) | |
m_clserial.BFSerialCancelRead(); | |
} | |
while (!m_readThread.Join(10)); | |
} |
Thursday, November 2, 2017
Cara membuat hotspot Wifi Windows 8 auto run di Start Up Program
Pertama buat file batch ( batch script, bat file atau DOS command file), simpan file di start up menu program. Lokasi foldernya biasanya di: "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" .
Di Windows 8 kita tidak bisa menjalankan file *.bat sebagai administrator, kita harus mengklik kanan kemudian pilih menu "run as administrator". Cara lainnya yaitu dengan membuat shortcut file link dari file *.bat tersebut kemudian pilih property, advance property, dan centang kotak checkbox "Run as administrator"
Dalam hal ini kendala utamanya adalah semua metode diatas membutuhkan operator untuk melakukannya. Yang mana kita harus selalu melakukan metode diatas berulang ulang setiap kali booting ulang atau restart windows.
Untuk solusi dari masalah tersebut adalah dengan menambahkan beberapa baris kode program di dalam file *.bat sehingga file *.bat tersebut dapat bekerja sebagai administrator secara otomatis tanpa memerlukan instruksi tambahan dari operator ataupun file tambahan. Berikut kode perintah program yang perlu ditambahkan dibaris pertama dari file *.bat nya.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: BatchGotAdmin (Run as Admin code starts) | |
REM --> Check for permissions | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
REM --> If error flag set, we do not have admin. | |
if '%errorlevel%' NEQ '0' ( | |
echo Requesting administrative privileges... | |
goto UACPrompt | |
) else ( goto gotAdmin ) | |
:UACPrompt | |
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
"%temp%\getadmin.vbs" | |
exit /B | |
:gotAdmin | |
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) | |
pushd "%CD%" | |
CD /D "%~dp0" | |
:: BatchGotAdmin (Run as Admin code ends) | |
:: Your codes should start from the following line |
File *.bat yang diawal baris telah ditulis kode perintah program seperti diatas maka akan menjalankan program sebagai administrator. Selanjutnya tambahkan kode perintah program berikut untuk mendaftarkan hotspot wifi SSID dan passwordnya.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
netsh wlan set hostednetwork mode=allow ssid=wifihotspotku key=1234asdf |
- SSID = adalah nama hotspot yang diinginkan, silahkan dirubah sesuai keinginan
- KEY = password atau security key dari hotspot yg dibuat
Apabila kode perintah sukses, maka respon dari OS adalah sebagai berikut.
Selanjutnya untuk mengaktifkan hotspot wifi yang telah didaftarkan diatas, tambahkan kode perintah program berikut.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
netsh wlan start hostednetwork |
Apabila kode perintah sukses, maka respon dari OS adalah sebagai berikut.
Kode perintah lengkapnya adalah sebagai berkut, selanjutnya simpan file dengan nama bebas, gunakan extension bat, dan taruh di dalam folder "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" agar pada saat windows start program batch ini akan langsung dieksekusi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: BatchGotAdmin (Run as Admin code starts) | |
REM --> Check for permissions | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
REM --> If error flag set, we do not have admin. | |
if '%errorlevel%' NEQ '0' ( | |
echo Requesting administrative privileges... | |
goto UACPrompt | |
) else ( goto gotAdmin ) | |
:UACPrompt | |
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
"%temp%\getadmin.vbs" | |
exit /B | |
:gotAdmin | |
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) | |
pushd "%CD%" | |
CD /D "%~dp0" | |
:: BatchGotAdmin (Run as Admin code ends) | |
:: Your codes should start from the following line | |
netsh wlan set hostednetwork mode=allow ssid=wifihotspotku key=1234asdf | |
netsh wlan start hostednetwork |
Selanjutnya klik "Change Adapter Setting" di pojok kiri atas, untuk melihat Semua koneksi network yang tersedia di komputer, termasuk koneksi hotspot yang telah dibuat sebelumnya.
Seperti dilihat pada screenshoot gambar diatas, hotspot yang baru dibuat dikenali sebagai "Local Area Connection* 4", dengan nama SSID adalah "AirborneCamHotSpot". Sekarang tinggal dipilih dari koneksi internet mana yang mau di share ke jaringan "Local Area Connection* 4". Bisa share internet dari Modem USB , Ethernet LAN ataupun dari WiFi luar.
Klik kanan pada koneksi network yang terhubung Internet (saat ini yang dicoba adalah dari Ethernet LAN yang terhubung dengan jaringan Internet Indihome SPEEDY), kemudian pilih property, klik tab "Sharing", dan kemudian centang checklist "Allow other network users to connect through this computer's Internet connection".
Kemudian pilih "Home networking Connection:" sesuai LAN hotspot yang telah dibuat tadi, yaitu: "Local Area Connection* 4". Selanjutnya centang juga cheklist "Allow other network users to control or disable the shared Internet connection) dan klik OK.
Dan selesai sudah semua, hotspot WiFi anda sudah siap diakses dari perangkat lain. Untuk mengeceknya silahkan cari dan coba sambungkan hotspot yang telah dibuat tadi dari WiFi Smartphone anda atau dari Laptop disekitar anda.
Subscribe to:
Posts (Atom)