Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading and Parsing trans.log file 4

Status
Not open for further replies.

hellbender3069

Programmer
Oct 18, 2012
12
NL
Hello Coorsman and TahoeMiah,
In a distant post you two have discussed the parsing of the trans.log file and did some research into its construction. I am currently in the need to filter some information from the logfile ( the tablenumber connected to a check ) and before I am going to reinvent te wheel I would like to ask if one of you two had some more inside into the trans.log structure. I have looked at it and found some information which I could use, but it would be nice to have a clear overview. Any information ( also from other knowledgable people ) is welcome.

A second question I have is : does anybody know what the files TOFOH.TXN and TOBOH.TXN are for and how to use them?? I know that they are probably used to insert transactions into the FOH or BOH ( duhh ) and they are polled every few seconds on the terminal.

With regards,
Michel
 
If your data doesn't have to be real time you could read it after the EOD from the gnd*.dbf files. Other than that here is what i dug up fro tofoh.txn:

''The (BOH) does not write directly to the TRANS.LOG (transaction log), it uses TOFOH.TXN files to send messages, instructions, and updates to the Front-of-House (FOH) master terminal, and the master terminal parses the data and appends the information to the transaction log. Examples include forcing the End-of-Day (EOD) process from the BOH and real-time updates to the FOH.

To update the FOH, the BOH places a TOFOH.TXN in the DATA folder. The master terminal recognizes the file, appends the information to the current transaction log, and deletes the TOFOH.TXN file.

Like the transaction log, the TOFOH.TXN uses a proprietary binary format, so you cannot view or edit it. ''





Cheers,
Coorsman

 
Hello Coorsman,
thanks for the answer. The problem with the GND tables it that it doesn't hold information about which table a check was registered to and that is just the information i need. The reprint tool shows me the tablenumber together with the checknumber and i noticed that it parses this information from the trans.log file. Looking at the trans.log file i indeed noticed that it was binairy, but it is not encrypted like people say. Things like the tablenumber and name are writen in visible binary or text.

I hoped the posts between you and TahoeMiah from 2011 yielded some results. Thanks anyway and I will start digging into the trans.log file and create a parser for it so I can get the info out.

Regards,
Michel
 
Good luck.
I know the fields are variable lenght and there is a key field to the lenght of each field and in squential order. There is alot of junk in there when looked at from the trans.log utility that allows you to view the log file.




Cheers,
Coorsman

 
Hi Coorsman,
this was more easy then i thought. It is nog encrypted like people say it is just binary. I have created a parser in PHP for the information i was looking for. If anyone is interested I could give you the code to work with. It is a project in progess, but it gives you an idea about how to create more readable code.

For a few more pieces of information I am looking at a new version of dumplogXXXX.exe

With regards,
Michel
 
TOBOH.TXN is used by Aloha Stored Value cards and possibly some more of their addon products to send information from the FOH to their programs running on the server.

This is what a price change from TOFOH.TXN looks like in the trans.log -

3 Term: 0 Type: CHANGE ITEM 07:51:29 PM Sun Jan 06, 2013 [ 107] (249)
Item id: 803

Yes a lot of information in the TRANS.LOG is in plain text like table number, item names, employee name/number, etc..
I'd be interested in the code, I suck at programming and anything you could provide would help my learning process.
 
I would't mind looking at the code as well. The major problem with dealing directly with the trans.log I see is each version is different. I wouldn't feel comfortable inserting a txn into it but for reporting I wouldn't see any harm in using it if you couldn't use a grind file to get information needed or if live information needed to be extracted.


Cheers,
Coorsman

 
translog.php
<?php

include("actions.php");
include("action_struct.php");

class Entry
{
public $Term;
public $Timestamp;
public $ActionID;
public $Action;
Public $Size;
Public $Data;
Public $DataStruct;
}


$sFilename = "C:\\temp\\trans.log";
$oFile = fopen($sFilename, "rb");
$iCount = 0;

if ( $oFile != false )
{
$aEntries="";
while ( !feof( $oFile ) )
{
$oData = fread($oFile,12);
$aData = unpack("LTerm/LTime/SAction/SSize", $oData);
$aEntries[$iCount] = new Entry();
$aEntries[$iCount]->Term = $aData["Term"];
$aEntries[$iCount]->Timestamp = date("H:i:s d-m-Y", $aData["Time"]-2209075200);
$aEntries[$iCount]->ActionID = $aData["Action"];
if ( isset( $aActions[$aData["Action"]] ) )
{
$aEntries[$iCount]->Action = $aActions[$aData["Action"]];
}
else
{
$aEntries[$iCount]->Action = $aData["Action"];
}
$aEntries[$iCount]->Size = $aData["Size"];
$aEntries[$iCount]->Data = fread($oFile,$aData["Size"]+1);
$aEntries[$iCount]->DataStruct = parseactiondata($aEntries[$iCount]->ActionID, $aEntries[$iCount]->Data);

print_r($aEntries[$iCount]);

//printf("%u\n", $aEntries[$iCount]->Timestamp);

$iTeller++;

//if ($iCount==50) die();
}

fclose($oFile);
}
else
{
echo "Can't find trans.log";
}
?>

actions.php
<?php

$aActions[15] = "Open Table";
$aActions[16] = "Close Table";
$aActions[17] = "Order Items";
$aActions[18] = "Order Items Video";
$aActions[19] = "Update Items";
$aActions[20] = "Delete Items";
$aActions[21] = "Clock in";
$aActions[26] = "Close check";
$aActions[27] = "Void check";
$aActions[28] = "Log in";
$aActions[29] = "Log out";
$aActions[50] = "Transfer table";
$aActions[51] = "Accept table";
$aActions[52] = "Add check";
$aActions[68] = "Apply payment";
$aActions[121] = "Open Item";
$aActions[161] = "Special message";
$aActions[181] = "Print Check";
$aActions[184] = "Terminal Up";
$aActions[242] = "Unlock Emploree";
$aActions[285] = "No Sale";
$aActions[299] = "Item Info 3";
$aActions[375] = "New Log";

?>

action_struct.php
<?php

function parseactiondata( $actionID, $sData )
{
$sFunction = "parse_" . $actionID;
if ( function_exists($sFunction) )
{
return call_user_func($sFunction,$sData);
}
else
{
return null;
}
}

function parse_15($sData)
{
$aData = unpack("cNul/LUnknown1/LEmployeeID/LTablenumber/a16Description/LTableID/cUnknown4/SType1/SType2/SUnknown5/LTimeStamp", $sData);
$aData["TimeStamp"] = date("H:i:s d-m-Y", $aData["TimeStamp"]-2209075200);
return $aData;
}

function parse_21($sData)
{
$aData = unpack("cNul/LUnknown1/LEmployeeID/cUnknown2/cUnknown3/cUnknown4/LJobcode/SHour/SMinute/SSecond", $sData);
return $aData;
}

function parse_28($sData)
{
$aData = unpack("cNul/LUnknown1/LEmployeeID/LTerminal/SHour/SMinute/SSecond/LTimeStamp", $sData);
$aData["TimeStamp"] = date("H:i:s d-m-Y", $aData["TimeStamp"]-2209075200);
return $aData;
}

function parse_29($sData)
{
$aData = unpack("cNul/LUnknown1/LEmployeeID/LTerminal/SHour/SMinute/SSecond", $sData);
return $aData;
}

function parse_52($sData)
{
$aData = unpack("cNul/LUnknown1/LEmployeeID/LTableID/LCheckID/SUnknown/LTimeStamp", $sData);
$aData["TimeStamp"] = date("H:i:s d-m-Y", $aData["TimeStamp"]-2209075200);
return $aData;
}

?>
 
this is a partial implementation. the opening tags from PHP are missing ( due to html tags ). I also don't advice anybody to insert data into the trans.log. The difference with the different versions are the actions that are supported. The log entries have the following structure :

1. unsigned long -> terminal ID
2. unsigned long -> timestamp
3. unsigned int -> actionID
4. unsigned int -> size of action structure in bytes;
5. byte -> always 0

Then you can read the action structure, for each action has his own structure. A few structures I have worked out. Since i was only interested in "open table" and "add check" I did not integrate the rest.

If you have questions, please feel free to ask.
 
hellbender3069 I was wondering if you could make the program available thru drop box or a file sharing program. And maybe a little more commenting on the program side. I'm not familular with php programming but would like to learn from your code. This would be a great assett to our little community here to be able to parse, split and re-write a trans.log file. Most of the errors deal with trans logs and the ability to access them for suppor would be a great help.


Cheers,
Coorsman

 
Hi everybody,
sorry for the delay but I had to do some other work before I could finish this.

I added a lot of comment to the files and put them on dropbox. The link is :
If you have any questions please do not hesitate to ask them.

Next Project -> Make my own terminal which can interact with the mainterminal ( so I can use webshop or tablet to order )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top