Templot Club forums powered for Martin Wynne by XenForo :

TEMPLOT 3D PLUG TRACK - To get up to speed with this experimental project click here.   To watch an introductory video click here.   See the User Guide at Bexhill West.

  • The Plug Track functions are experimental and still being developed. Some of the earlier pages of this topic are now out-of-date.

    For an updated overview of this project see this topic.   For some practical modelling aspects of using Plug Track see Building 3D Track.

    The assumption is that you have your own machines on which to experiment, or helpful friends with machines. Please do not send Templot files to commercial laser cutting or 3D printing firms while this project is still experimental, because the results are unpredictable and possibly wasteful.

    Some pages of this and other topics include contributions from members who are creating and posting their own CAD designs for 3D printing and laser-cutting. Do not confuse them with Templot's own exported CAD files. All files derived from Templot are © Martin Wynne.
  • The Plug Track functions are experimental and still being developed.

    For an updated overview of this project see this topic.   For some practical modelling aspects of using Plug Track see Building 3D Track.

    The assumption is that you have your own machines on which to experiment, or helpful friends with machines. Please do not send Templot files to commercial laser cutting or 3D printing firms while this project is still experimental, because the results are unpredictable and possibly wasteful.

    Some pages of this and other topics include contributions from members who are creating and posting their own CAD designs for 3D printing and laser-cutting. Do not confuse them with Templot's own exported CAD files. All files derived from Templot are © Martin Wynne.

Lazarus-> addressing peripherals

Quick reply >

Derek

Member
Location
UK, Midlands
Hello Martin/ anyone

I have once again started working with Lazarus, this time more out of necessity than interest. At work we are served by a few IT providers that are constantly messing us about. One area of programming that I've found quite easy is databases (using SQLite or MYSql etc) and to that end I have developed several basic, but functional tools for work, which I believe I can fine tune into workable tools within a few months- these are mainly accounting packages and vehicle maintenance database.

However, I am also trying to produce a point of sale (POS) system, which really is just a database of product and a calculator to total a transaction before then writing the transaction into a new database. Writing Templot MK5? Impossible. Writing a few databases? Easy and relaxing.

However, in each of these scenarios to be fully compliant I need to be able to pass data to third parties, whether electronic submission to the revenue, or logs to DVSA or in the POS case to be able to send data to a contactless card device and receive its instructions back.

I know it's unlikely that anyone here is going to know the specifics of those examples, but I think it is going to work something similar in principle to how Martin first used his computer programmes to drive CAM systems (IIRC). I know each case will be different, but what I'm trying to understand is the principle of how someone does that. Presumably there's something in Lazarus to the effect of "open port XYZ, send ABC, wait for DEF response." But I cannot find anything on the internet as I don't really know what to search for.

Does anyone have any suggestions, please? I'm just looking for ideas of how to better search. Ultimately I suspect I am going to have to contract these bits out, but I need to understand what/ how/ why before I do that.

TIA
Derek
 
_______________
message ref: 3719
@Derek

Hi Derek,

What you call "easy and relaxing" doesn't strike me as such at all. :) Templot is much easier!

Presumably there's something in Lazarus to the effect of "open port XYZ, send ABC, wait for DEF response." But I cannot find anything on the internet as I don't really know what to search for.

For me the first question in anything like that is about the hardware. Are you talking about accessing a hardware device such as a card reader over a USB cable? Or a scanner? Or something networked via ethernet or wifi? Or a Bluetooth device?

The starting point is to get the technical manual for the device, to find out what inputs it is expecting and what outputs might be received back.

For accessing such hardware in Lazarus, see:

https://wiki.lazarus.freepascal.org/Hardware_Access

The Synapse package (included in the T3 open-source version of Templot for internet access) includes the SynaSer serial library for serial connections such as USB in Delphi/Lazarus. It's all a bit old-hat and out of date, but still works:

http://synapse.ararat.cz/doku.php

I hope the above links help with what you are asking about, but I fear we may be at cross-purposes. I'm sure there are some IT gurus on here who can help. :)

cheers,

Martin.
 
_______________
message ref: 3720
Hi Derek,

Martin has essentially outlined exactly how I would approach this. It depends on the device you are communicating with and how that communication takes place, both at the hardware level (older POS devices usually had a serial (or, even worse, parallel) connection - these days more likely to be USB) and at the application level i.e. what data is sent and received. Once you know all that it's easy! :ROFLMAO:

For a different take, you may want to look at https://github.com/itmitica/laddiso. There he uses calls to the Unix shell to run various programs which get the job done. That could provide an alternative if you can communicate with the device from a command line. If standard commands don't do it and you are comfortable with C/C++ coding that could give you another option, but the links suggested by Martin would be my first choice.

BUT I think your question may have been more about what search terms to use. For this I used "Lazarus writing usb", "Lazarus writing serial", "Lazarus writing hardware", etc (always using DuckDuckGo, of course. Do you LIKE Google tracking your every action?)

Good luck with this.

Cheers

graeme
 
_______________
message ref: 3721
Thanks Martin/ Graeme

Although it's different hardware to what I was looking at, I've found one company that- for a fee- will provide a software developer kit. I think my first stop (provided our bean counter at work permits) is to buy one terminal and the SDK and see what happens. Because this will ultimately need to be certified as 'somethingorother' compliant, it will probably need to be written or at least completed by a professional. But I really hate the idea of contracting out anything to someone unless I know at least the basics of how it's done- otherwise you tend to end up paying 10 times the going rate for 10th of the work you expected.

As I understand it- and correct me if I'm wrong- if I install the DEVICE.LIBRARY then whether I am using Lazarus, Delphi, Java, Python doesn't matter, I just (in English) call that library- telling it the input and waiting for its reply. Or would it need a different library for each of those programming languages. I am not sure that Delphi/ Lazarus is a common language for the type of project I'm working on.

On a positive note, as I mentioned I am pretty reasonable with databases, I am working on a web based sales version of this- my own custom 'shop' and currently 'wired' to Sagepay sandbox. So far it seems pretty good and I'm quite pleased. I am just trying now to check its security- I've already found the danger of 'injected code' and had to re-write it. But it is essentially just a simple set of databases with a front end PHP page. Nothing as complex as what I'm about to try.

Thanks again.
Derek
 
_______________
message ref: 3722
As I understand it- and correct me if I'm wrong- if I install the DEVICE.LIBRARY then whether I am using Lazarus, Delphi, Java, Python doesn't matter,
@Derek

Hi Derek,

Sorry, impossible to answer that without a link to the DEVICE.LIBRARY you are talking about. It could be anything. :confused:

If it's a Windows DLL file (.dll), or more likely a collection of DLL files:

https://en.wikipedia.org/wiki/Dynamic-link_library

you should be able to access the DLL files from any programming language.

In Delphi/Lazarus you can simply create a call to a .dll file as a callable function like any other by adding:

Code:
StdCall; external 'dll_name.dll';

to the function declaration:

Code:
function calc_diagonal(width,height:double):double; StdCall; external 'pythogoras.dll';

which you can then call just like any other function you have declared:

Code:
diagonal_of_rectangle:=calc_diagonal(rect_width,rect_height);

But of course, you would need the docs for the pythogoras.dll to know that. And remember to include the DLL file in your installer.

cheers,

Martin.
 
_______________
message ref: 3723
Many thanks, Martin. That seems quite straightforward and more or less what I was expecting.

By 'device.library' I did in fact mean .dll files- apologies, I couldn't think of what they were. filename.library is something going back to Commodore Amiga days, which is worrying.

The SDK isn't expensive, but the hardware to test it on is quite pricey, if this turns out to be an aborted move. It is annoying to think that I have 90% of the knowledge for this project already, but the last 10% will be the hardest. But necessity being the Mother of invention, so I'll give it a go.

Thanks again
Derek
 
_______________
message ref: 3776
Back
Top