07-16-2008 03:15 AM
Description of the communication protocol
The communication between Client and Server application is based on request – response rule. Client application side requests and server side responses to it.
Request is sent by the Client to the Server side. Type of request (and the response as well) is recognized by command number (field
Command in the sent structure). Next, depending on type of request, Server responses to client by sending requested data.The frame structure is like shown below:
FRAME = HEADER + DATA
Header consists of following fields:
[
StructLayout(LayoutKind.Sequential, Pack = 1)]public struct
Header{
public ushort
Command;public int
Lenght;public ushort
CommandNo;}
Command types and numbers are shown below:
/// <summary>
///
Commands sent between client and server./// </summary>
public enum
Commands{
LAN_CODE_GET_GPS_INFORMATION = 0x0005,
LAN_CODE_GPS_INFORMATION = 0x0006,
INTERNAL_CODE4 = 0x0007,
INTERNAL_CODE5 = 0x0008,
INTERNAL_CODE6 = 0x0009,
}
This request is sent by the client in order to calculate and send new position on the track by the server. Server reacts on it by sending calculated data in response described in 4.2.2 paragraph.
ushort Command = LAN_CODE_GET_GPS_INFORMATION = 0x0005
int Length = sizeof(Header)
ushort CommandNo – unknown value (next message number)
No additional data.
This response is reaction to "Calculate and send new position" request (paragprah 4.1.1). The position (and additional data) is sent in packed GPSInfo structure.
ushort Command = LAN_CODE_GPS_INFORMATION = 0x0006
int Length = sizeof(Header) + sizeof(GPSInfo)
ushort CommandNo – unknown value (next message number)
Data is sent binary in structure shown below packed to byte array.
/// <summary>
/// Structure containing calculated data with additional info.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct GPSInfo
{
/// <summary>
/// Calculated position.
/// </summary>
public PositionSt Position;
/// <summary>
/// Section id, on which train is.
/// </summary>
public int IdSection;
/// <summary>
/// USISID, on which train is.
/// </summary>
public double USISID;
/// <summary>
/// Actual mileage (in section).
/// </summary>
public double SectionMileage;
/// <summary>
/// Begin mileage of the section.
/// </summary>
public double SectionBeginMileage;
/// <summary>
/// End mileage of the section.
/// </summary>
public double SectionEndMileage;
/// <summary>
/// Mileage from odometer.
/// </summary>
public double OdometerMileage;
/// <summary>
/// Structure describing batteries status of the GPS.
/// </summary>
public BatteriesSt Batteries;
/// <summary>
/// Actual time.
/// </summary>
public double DateTimeInfo;
/// <summary>
/// Actual speed.
/// </summary>
public double Speed;
/// <summary>
/// Defines if navigation needs choosing leg by the user.
/// </summary>
public int NeedChoosing;
/// <summary>
/// Defines if sent position is unknown (when we don’t know on which leg we are)
/// </summary>
public int PositionUnknown;
/// <summary>
/// Number of the first leg.
/// </summary>
public double Leg1;
/// <summary>
/// Number of the second leg.
/// </summary>
public double Leg2;
/// <summary>
/// Defines if section, on which we are is properly defined in database.
/// </summary>
public int WrongObject;
/// <summary>
/// Defines ‘virtual’ mileage of the non-properly defined section.
/// </summary>
public int WrongMileage;
/// <summary>
/// Non calculated raw gps position.
/// </summary>
public PositionSt RawGPSPosition;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct BatteriesSt
{
/// <summary>
/// Percentage of batteries load.
/// </summary>
public double Percentage;
/// <summary>
/// Voltage of the batteries.
/// </summary>
public double Voltage;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PositionSt
{
public double X;
public double Y;
public double Z;
}
07-16-2008 05:15 AM
Hi Guilly,
what do you expect from us? Do you want to learn how to do this, or do you want a ready "client"?
Mike
07-29-2008 10:40 AM
07-29-2008 10:47 AM
07-29-2008 10:56 AM
07-29-2008 11:36 AM
07-29-2008 12:10 PM
You can look under the Help Menu and select > Find Examples and do a search on TCP IP. You should find some examples of LV code.
Have a look at the following threads. I will try to place some that are either relevant, or contain examples of code, or issues that you may see as you write the code.
THis one has an example: http://forums.ni.com/ni/board/message?board.id=170&message.id=79711&query.id=147925
Here is an article: http://zone.ni.com/devzone/cda/tut/p/id/4579
TCP Architecture (multiple clients) : http://zone.ni.com/devzone/cda/tut/p/id/3982
That should get you started. Look at the examples, and then build your application. You can then continue to ask questions in this thread if you need more help.
R
07-29-2008 12:37 PM
For the record, nobody is accusing you of "taking the easy ride". Your post just seemed like many others that have been seen before where people are asking others to do their work (or homework) for them. So, before getting defensive, take the advice that has already been given, like going through the LabVIEW tutorials, as it seems you are asking about how to code in LabVIEW, and looking at the examples that already ship with LabVIEW. This will allow you to ask more specific questions that can be better answered.
@Guilly wrote:
So instead of accusing me taking the easy ride, is there someone who can help me out?
07-29-2008 01:34 PM
07-29-2008 05:50 PM - edited 07-29-2008 05:50 PM