Qt Type Convertor

// int to QString
QString::number(int)

// 

Qt Timer

Other way is using of built-in method start timer & event TimerEvent. Header:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    int timerId;

protected:
    void timerEvent(QTimerEvent *event);
};

#endif // MAINWINDOW_H
Source:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    timerId = startTimer(1000);
}

MainWindow::~MainWindow()
{
    killTimer(timerId);
    delete ui;
}

void MainWindow::timerEvent(QTimerEvent *event)
{
    //qDebug() << "Update...";
    ui->label->setText(QString::number(m_count++)); 
}

Telnet server in IMX6 Linux OS

* mkdir /dev/pts
* mount -t  devpts devpts /dev/pts
*telnetd -l /bin/login

TFTP Server in Ubuntu

  1. Install following packages.
    sudo apt-get install xinetd tftpd tftp
    
  2. Create /etc/xinetd.d/tftp and put this entry
    service tftp
    {
    protocol        = udp
    port            = 69
    socket_type     = dgram
    wait            = yes
    user            = nobody
    server          = /usr/sbin/in.tftpd
    server_args     = /tftpboot
    disable         = no
    }
    
  3. Create a folder /tftpboot this should match whatever you gave in server_args. mostly it will be tftpboot
    sudo mkdir /tftpboot
    sudo chmod -R 777 /tftpboot
    sudo chown -R nobody /tftpboot
    
  4. Restart the xinetd service.
    sudo /etc/init.d/xinetd restart
    
    Now our tftp server is up and running.

    ## TFTP from Target
    GET: tftp -l [local file name] -r [remote file name] -g [server Ip]
    PUT: tftp -l [local file name] -r [remote file name] -p [server Ip]

Linux Commands

// Share Windows and VMWare
.. Enable and Create Share folder in VM -> Settings -> Share Folder >.......
.. linux command :  mkdir /mnt ...if mnt doesn't exit
                             sudo mount -t vmhgfs .host /mnt

Set up Qt 5.2 Environment

 Install curl program if system don't support
# apt-get install curl

To get repo script
#curl http://commondatastorage.googleapis.com/git-repo-downloads/repo
> repo

Change permission of repo
#chmod a+x repo

Create BSP folder and go in
#mkdir fsl-community-bsp
#cd  fsl-community-bsp

Download BSP
#../repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b dora
#../repo sync

Install SDK

Prepare the environment:
$MACHINE=imx6qsabresd . ./setup-environment build

Compile the SDK:
$sudo apt-get install texinfo
$sudo apt-get install gawk
$sudo apt-get install chrpath
$bitbake fsl-image-test -c populate_sdk   //Take long time to install



//Fail




RFID IC Model and Manufacturer List


EPC RFID MDID List:  http://www.gs1.org/epcglobal/standards/mdid

 Monza 5 Datasheet: https://support.impinj.com/hc/en-us/article_attachments/200775538/Monza_5_Tag_Chip_Datasheet_3-24-14.pdf

NXP RFID IC datasheet : http://www.nxp.com/documents/data_sheet/SL3S1203_1213.pdf

The User Profile Service failed the logon in Windows 7

To fix the user account profile, follow these steps: 

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows How to back up and restore the registry in Windows
  1. Click Start, type regedit in the Search box, and then press ENTER.
  2. In Registry Editor, locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
  3. In the navigation pane, locate the folder that begins with S-1-5 (SID key) followed by a long number.
  4. Click each S-1-5 folder, locate the ProfileImagePath entry in the details pane, and then double-click to make sure that this is the user account profile that has the error.
    2705065

    • If you have two folders starting with S-1-5 followed by some long numbers and one of them ended with .bak, you have to rename the .bak folder. To do this, follow these steps:
      1. Right-click the folder without .bak, and then click Rename. Type .ba, and then press ENTER.
        2493038
      2. Right-click the folder that is named .bak, and then click Rename. Remove .bak at the end of the folder name, and then press ENTER.
        2493039
      3. Right-click the folder that is named .ba, and then click Rename. Change the .ba to .bak at the end of the folder name, and then press ENTER.
        2493040
    • If you have only one folder starting with S-1-5 that is followed by long numbers and ends with .bak. Right-click the folder, and then click Rename. Remove .bak at the end of the folder name, and then press ENTER.
  5. Click the folder without .bak in the details pane, double-click RefCount, type 0, and then click OK.
    2493045
  6. Click the folder without .bak, in the details pane, double-click State, type 0, and then click OK.
    2493046
  7. Close Registry Editor.
  8. Restart the computer.
  9. Log on again with your account
More Details: http://support.microsoft.com/kb/947215

Get Wifi Signal in Windows CE 6.5

 foreach (var ni in NetworkInterface.GetAllNetworkInterfaces())
            {
                //var wzc = ni as WirelessZeroConfigNetworkInterface;
                //if (wzc != null)
                //{
                //    MessageBox.Show("WZC Signal: " + 
                      wzc.SignalStrength.Decibels+":"+wzc.Name);
                //    StrengthType st = wzc.SignalStrength.Strength;
                //    switch (st)
                //    {
                //        case StrengthType.NoSignal:
                //            break;
                //    }
                //    continue;
                //}

                var wni = ni as WirelessNetworkInterface;
                if(wni != null)
                {
                    StrengthType strength = wni.SignalStrength.Strength;
                    switch (strength)
                    {
                        case StrengthType.NoSignal: Program.batteryandtime.WifiUpdate(0);
                            label1.Text = "NoSignal";
                            wifi_strength = 0;
                            break;
                        case StrengthType.NotAWirelessAdapter:
                            Program.batteryandtime.WifiUpdate(0);
                            label1.Text = "NotAWirelessAdapter";
                            wifi_strength = 0;
                            break;
                        case StrengthType.Excellent:Program.batteryandtime.WifiUpdate(3);
                            label1.Text = "Excellent";
                            wifi_strength = 3;
                            break;
                        case StrengthType.VeryGood:Program.batteryandtime.WifiUpdate(3);
                            label1.Text = "VeryGood";
                            wifi_strength = 3;
                            break;
                        case StrengthType.Good:Program.batteryandtime.WifiUpdate(2);
                            label1.Text = "Good";
                            wifi_strength = 2;
                            break;
                        case StrengthType.Low: Program.batteryandtime.WifiUpdate(1);
                            label1.Text = "Low";
                            wifi_strength = 1;
                            break;
                        case StrengthType.VeryLow: Program.batteryandtime.WifiUpdate(1);
                            label1.Text = "VeryLow";
                            wifi_strength = 1;
                            break;
                    }
                   
                                    
                    continue;
                }

                MessageBox.Show("No signal info available");
            }              

Note : To use  OpenNetCF.Net.dll (2.3.12004.0)
Solved Problem:

Control Pannel-> Programs and Features-> Turn Windows Features on or off -> Internet Information Service-> World Wide Web-> Application Development Features->ASP.Net (Checked)

Binary File Uploading by Web Serviece

       [WebMethod]
        public void UploadLogFile(byte[] buffer, string filename)
        {
            if (!Directory.Exists("D:\\EEMS\\EHTLog\\" + DateTime.Now.ToString("yyyyMM")))
            {
                Directory.CreateDirectory("D:\\EEMS\\EHTLog\\" +  
                DateTime.Now.ToString("yyyyMM"));
            }
            BinaryWriter binWriter = new
            BinaryWriter(File.Open("D:\\EEMS\\EHTLog\\" +
            DateTime.Now.ToString("yyyyMM") + "\\" + filename, FileMode.CreateNew,
            FileAccess.ReadWrite));
            binWriter.Write(buffer);
            binWriter.Close();
        }

Convert UT8 to GB2312 (Chinese Encoding)

            string GBInfo = string.Empty;
            Encoding utf8 = Encoding.UTF8;
            Encoding gb2312 = Encoding.GetEncoding("gb2312");
            byte[] UnicodeBytes = utf8.GetBytes(str);
            byte[] AscIIBytes = Encoding.Convert(utf8, gb2312, UnicodeBytes);
            char[] AscIIChars = new char[gb2312.GetCharCount(AscIIBytes, 0,   
            AscIIBytes.Length)];
            gb2312.GetChars(AscIIBytes, 0, AscIIBytes.Length, AscIIChars, 0);
            return AscIIBytes;

UTF-8 data from mssql to C# UTF-8 by SQLReader

byte[] bytes = Encoding.GetEncoding(1252).GetBytes(m_orderdetail.productDescCN);//((string)reader["Note"]);
m_orderdetail.productDescCN = Encoding.UTF8.GetString(bytes);

Error: 5133 SQL Server while attaching the Database

Today, one of my support executive was trying to attach a database received from client in SQL SERVER 2008 R2. He had received only one file, DemoDB.mdf

Now when he was attaching that file, SQL server is giving below error:

TITLE: Microsoft SQL Server Management Studio
------------------------------
Attach database failed for Server 'XXX-XX--XX'.  (Microsoft.SqlServer.Smo)


For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.2500.0+((KJ_PCU_Main).110617-0038+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Directory lookup for the file "G:\SQLLOG\NAV_D_CQPA_370B_Log.ldf" failed with the operating system error 3(The system cannot find the path specified.). (Microsoft SQL Server, Error: 5133)
------------------------------

I checked the file path during attach. I found that as he does not have the log file. SQL was taking a random path which is not exist in the system. I removed the ldf file and the database is attached successfully.

ေလ႕လာစရာ နည္းပညာမ်ား

1. SQL Server for developer
2. IIS 8
3. dot Net Framework 4.5
4. Entity Framework
5. WCF & RIA WCF
6. Business Silverlight 5
7. LINQ
8. T-SQL