|
Hi,
I would like to ask about the magnetic strips on the cards?
How can I read the data?
is it just a raw data just like the bard code and I have to split it? or it's encrypted and needs special way to read?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Depends on the card, depends on the reader.
What are you trying to do?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I am trying to do a loyalty card. I don't have anything yet
I will purchase zebra printer with its encoder but I want to develop the application which will read the magnetic stripe and do the required task accordingly.
Technology News @ www.JassimRahma.com
|
|
|
|
|
Then talk to the manufacturers and see what they can provide!
They may do several versions...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
you mean there is no standard way of storing the data on magnetic stripes?!
Technology News @ www.JassimRahma.com
|
|
|
|
|
It's not the data side you need to worry about, it's the API for the reader. You aren't actually be reading the card, the reader does - what you need to do is interpret the output from the reader.
|
|
|
|
|
One interfaces with the "card reader"; which could be a USB device; which is opened and read (when armed) as a file stream.
The card's strip would contain some fields and "tracks" of data at particular offsets in the card reader "file".
You need to extract the required fields (using offsets and lengths), wrap them as strings in a "transaction", and typically send them to a "payment processor" (or whatever) via a web service.
The data is encrypted; the client does not decrypt it; it is sent "as is" (with say a $ amount) to the credit card data processor who decrypts the credit data; verifies it; approves the transaction; or declines it; by sending a web service response back to the client.
|
|
|
|
|
HI,
I am facing an issue , from my client side (HTTPS browser) I am trying to connect a HttpTaskAsyncHandler in the project
Eg:
var webSockets = new WebSocket("wss://xxx.com//Racer.HTML5/WSHandlerCall));
if (webSockets != null) {
webSockets.onopen = function () {
alert('Connection open');
}
webconfig:
<system.webServer>
<handlers>
<add name="WebSocketHandler" verb="*" path="WSHandlerCall" type="Racer.HTML5.WebSocketHandler,Racer.HTML5" resourceType="Unspecified" />
</handlers>
</system.webServer>
<appSettings>
<add key ="wsURL" value="/Racer.HTML5/WSHandlerCall"/>
1.The sockets send a request.
2. OnOpen Listener is triggered but not called the handler.
Plz Help !!
modified 15-Jul-14 14:42pm.
|
|
|
|
|
That looks amazingly like JavaScript to me.
|
|
|
|
|
It does seem to be like a JS issue , since the Wireshark did not respond with RESPONSE: 101 switching protocol
Also added the webconfig in the above thread...
Plz help..
modified 15-Jul-14 14:43pm.
|
|
|
|
|
I am working on a project where I have to integrate with an intelligent network using MML commands in C#. I have managed to connect to the target server using sockets. Now I want to transmit the appropriately formatted data to the server. That is to Encode the message then decode the response. I have code examples in C++ which I am finding quite cryptic.
Can anyone show me how I can implement this in C#
#define MAX_LEN_VERSION 4
#define MAX_LEN_TERMINAL 8
#define MAX_LEN_SERVNAME 8
#define MAX_LEN_DLGCTRL 6
#define MAX_LEN_TXID 8
#define MAX_LEN_TXCTRL 6
#define MAX_LEN_TXRSVD 4
#define MAX_MSG_LEN 65536
#define MAX_HEAD_LEN 56
#define MSG_STARTTAG_LEN 4
#define MSG_INFOLEN_LEN 4
#define MSG_CHKSUM_LEN 4
#define MSG_COMM_LEN 12
#define MAX_HB_MSG_LEN 4
#define MAX_HB_CONTENT_LEN 4
#define MAX_HB_CHCKSUM 4
#define HB_MSG_LEN 16
#define MAX_LEN_DLGID 8
#define MAX_LEN_DLGRSVD 4
#define MSG_STARTTAG "\x1C\x1D\x1E\x1F"
#define MSG_VERSION "1.00"
#define MSG_TERMINAL "internal"
#define MSG_TXRSVD " "
#define MSG_DLGRSVD " "
#define HB_CONTENT "HBHB"
EnRet Encode(MsgInfo & sendMsg, char * sendBuff, int & sendLen, int send_type)
{
if (TYPE_OF_HB_MSG == send_type)
{
int temp_len;
char * p_num, hb_checksum[MAX_HB_CHCKSUM];
temp_len = 0;
strncpy(sendBuff + temp_len, MSG_STARTTAG, MSG_STARTTAG_LEN);
temp_len += MSG_STARTTAG_LEN;
p_num = Int2ToHex(HB_MSG_LEN);
strncpy(sendBuff + temp_len, p_num, MAX_HB_MSG_LEN);
temp_len += MAX_HB_MSG_LEN;
strncpy(sendBuff + temp_len, HB_CONTENT, MAX_HB_CONTENT_LEN);
temp_len = MSG_STARTTAG_LEN + MAX_HB_MSG_LEN;
GetChkSum(MAX_HB_MSG_LEN, sendBuff + temp_len, hb_checksum);
temp_len = HB_MSG_LEN - MAX_HB_CHCKSUM;
strncpy(sendBuff + temp_len, hb_checksum, MAX_HB_CHCKSUM);
printf("\ncode HB secceed!\n%s", sendBuff);
return Success;
}
Int msglen, cmdlen, len;
char *p, chksum[MSG_CHKSUM_LEN];
char *pTx[] = { "TXBEG", "TXCON", "TXCAN", "TXEND" };
char *pDlg[] = { "DLGLGN", "DLGBEG", "DLGCON", "DLGEND" };
PrintMsg(sendMsg);
cmdlen = strlen(sendMsg.cmd);
msglen = MAX_HEAD_LEN + cmdlen;
len = (4 - msglen % 4);
msglen += len;
sendLen = msglen + MSG_COMM_LEN;
memset(sendBuff, ' ', MAX_MSG_LEN);
len = 0;
strncpy(sendBuff + len, MSG_STARTTAG, MSG_STARTTAG_LEN);
len += MSG_STARTTAG_LEN;
p = Int2ToHex(msglen);
strncpy(sendBuff + len, p, MSG_INFOLEN_LEN);
len += MSG_INFOLEN_LEN;
strncpy(sendBuff + len, MSG_VERSION, MAX_LEN_VERSION);
len += MAX_LEN_VERSION;
strncpy(sendBuff + len, MSG_TERMINAL, MAX_LEN_TERMINAL);
len += MAX_LEN_TERMINAL;
strncpy(sendBuff + len, sendMsg.service, strlen(sendMsg.service));
len += MAX_LEN_SERVNAME;
p = Int4ToHex(sendMsg.snLogin);
strncpy(sendBuff + len, p, MAX_LEN_DLGID);
len += MAX_LEN_DLGID;
strncpy(sendBuff + len, pDlg[sendMsg.dlgCtrl], strlen(pDlg[sendMsg.dlgCtrl]));
len += MAX_LEN_DLGCTRL;
strncpy(sendBuff + len, MSG_DLGRSVD, MAX_LEN_DLGRSVD);
len += MAX_LEN_DLGRSVD;
p = Int4ToHex(sendMsg.sequence);
strncpy(sendBuff + len, p, MAX_LEN_TXID);
len += MAX_LEN_TXID;
strncpy(sendBuff + len, pTx[sendMsg.txCtrl], strlen(pTx[sendMsg
.txCtrl]));
len += MAX_LEN_TXCTRL;
strncpy(sendBuff + len, MSG_TXRSVD, MAX_LEN_TXRSVD);
len += MAX_LEN_TXRSVD;
strncpy(sendBuff + len, sendMsg.cmd, cmdlen);
len = MSG_STARTTAG_LEN + MSG_INFOLEN_LEN;
GetChkSum(msglen, sendBuff + len, chksum);
len = sendLen - MSG_CHKSUM_LEN;
strncpy(sendBuff + len, chksum, MSG_CHKSUM_LEN);
return Success;
}
|
|
|
|
|
That's rather a tall order and not a trivial task. You would be better advised to start from scratch using the documentation for MML and the design requirements for your project. Encoding and decoding messages is not that difficult in C#, either use the String class methods to split or concatenate data, or use byte arrays if the data is fixed length.
|
|
|
|
|
I have been asked to refactor a couple of modules which are extremely critical with respect to the performance and are already taking a few seconds more than the desired time. So, they later will be worked on performance optimizations as well.
I have come across following block of code:
foreach
foreach
foreach
end
end
end
I was thinking to refactor the statements ((##) above). But as per my knowledge, method calls do take finite amount of execution time for push/pop onto/from the stack. Considering these modules are really critical w.r.t. the performance (as in any other relevant scenario):
0. Should I really be considering function-call times while dealing with performance?
1. Should I really go ahead with refactoring the above statements (especially for those which involve significant number of push/pop operations)?
1.1. If yes, should I refactor those statements to methods only in current DLL or the external one is also feasible?
Any pointers will be appreciated. Thanks!
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
That is: the inner loop is executed about 2 million times?
Do iterations depend on each other? I.e. can you parallelize them, e.g. by starting new threads in the outer loop for each middle loop?
|
|
|
|
|
Bernhard Hiller wrote: the inner loop is executed about 2 million times? Unfortunately, yes..
Bernhard Hiller wrote: can you parallelize them, Unfortunately no, since the processing order till the innermost loop needs to be enforced..
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Even parallelise the inner loop can make a difference...Think about it...
It's hard to say if bringing external functions into the loop body will reduce execution time. Most cases it does, but it very depend on your code...
One think that can reduce execution time is better design of your critical code:
1. Remove as much conditional statements as you can
2. Declare and initialize locals only if you have to
3. Find and eliminate of unnecessary computations (e.g. do not compute the square-root of a number but use lookup variable)
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thank you for your suggestions, I will see how I can apply those.
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Depends on how much work the inner loop is doing: the setup cost of a thread is not insignificant, and the total overhead can extend the processing time - parallelizing works best when is a few long running tasks, and badly when it's significantly more tiny tasks than cores!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
If you are seriously considering performance, and have issues already then refactoring inline code to methods will make the problem worse, not better: there is a small overhead in each method call that is not present in the inline version. Depending on parameter usage, it can become less than trivial, particularly when executed in nested loops. And you are executing that code 2,250,000 times, so any small increase in execution time can become significant when considered against the loop as a whole.
I'd start with looking at the code and the loops and seeing exactly what they all do, and if it's necessary before refactoring the code: at the moment it's fairly obvious how it's all interrelated and is anything can be moved out of the loop. Refactoring that into multiple DLLs would make that process a lot, lot harder.
But before you do anything add some timing code to monitor what is actually happening, so you can tell exactly if what you did improved or worsened the situation - and remember that the Release version will have different timings to teh Debug as it includes a lot more optimisations!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Sure, thanks!
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Slightly off-topic but I was working on a little additive synthesis hobby application recently where I needed to sum together hundreds of sine waves 48,000 times a second. I spent quite a while getting it as fast as I could.
First observation is that computers are really blood quick these days.
Obviously Math.Sin was too slow so used a wavetable.
Floats were too slow so used 32-bit signed integers (this seems to vary by processor quite a lot)
Arrays have bound checking so moved into the unsafe domain
Repeated the actual business code inside the loop (copy and paste) so less iterations needed (better setting to looping ratio + to avoid pipeline flushes on processor)
But, the killer improvement I got was not to use member variables in the loops. By copying member data to local variables, doing all the calculations with this then updating member variables from the locals at the end it speeded up several fold. I think this is because the locals were assigned to a register and didn't need to be written back and forth to memory continually.
I can't remember what the stats were but they were outstanding, perhaps something in the order of 50,000 oscillators at 48KHz.
Regards,
Rob Philpott.
|
|
|
|
|
Yes local variables can make a big difference - but Release optimisations should do that for you anyway, in theory.
Computers are indeed damn quick these days, but it's still true that a good, experienced coder can beat the compiler sometimes!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
The whole release/debug thing is pretty blurred in my mind in .NET. I'm not sure that optimization can be made due the hideously complex business of multiple cores with caching at various levels.
I actually need to get to the bottom of the exact differences between debug and release. In C++ it was very clear, but it is much more confusing with 2 stage compilation. Debug code may have NOPs in it, but the jitter can just not bother do anything with these. I think. Really apart from the odd optimization the MSIL should be the same in either case.
There might be an article in there somewhere..
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: apart from the odd optimization the MSIL should be the same in either case.
Nope, not even close: http://www.hanselman.com/blog/ReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx[^] and that's just an investigate into inlining! The loop optimization is reportedly very good, and so is the localization of variables.
This is one reason why it's important to do any performance timing / tuning against Release builds rather than debug - because the compiler can easily remove two days work shaving a couple of seconds off!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Interesting read - thanks.
>An anti-pattern is "a pattern that tells how to go from a problem to a bad solution."
I like that definition.
Yes, I need to do my homework here. I may share it one day!
Regards,
Rob Philpott.
|
|
|
|
|