API information / manual

If you have a question about the software please ask it here.

API information / manual

Postby Robertspark » Mon Oct 21, 2019 10:34 am

just wondering if there is any information or manual on the API / making use of it?
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: API information / manual

Postby cncdrive » Mon Oct 21, 2019 1:40 pm

Hi Rob,

It does not have a separate documentation.
The documentation is the C# wrapper file which has basic description of the functions, it is Intellisense documented.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: API information / manual

Postby Robertspark » Mon Oct 21, 2019 2:12 pm

thanks,
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: API information / manual

Postby eabrust » Fri Nov 01, 2019 12:45 pm

cncdrive wrote:Hi Rob,

It does not have a separate documentation.
The documentation is the C# wrapper file which has basic description of the functions, it is Intellisense documented.



Hi Balazs,

Is there plans to make/release a VB wrapper file?

I was able to make use of the C# wrapper and compile a test plugin that gave access to the UC100 API, but I'm more comfortable (barely... :) ) working in VB.

regards,
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 357
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: API information / manual

Postby cncdrive » Fri Nov 01, 2019 4:20 pm

Hi Eric,

Did you try this code converter?
https://codeconverter.icsharpcode.net/
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: API information / manual

Postby eabrust » Fri Nov 01, 2019 5:21 pm

Thanks for reply Balazs,

I did try to convert the C# wrapper using a few other online converters with no luck or errors produced. I will try this one and report if it works. If it works, do you oppose if I post the converted wrapper?

If that fails, I'm also under the impression that I can pre-compile just the C# wrapper and use it in a VB project. That is based on some reading/searching, but I also haven't yet tried that. That will be plan B.

regards
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 357
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: API information / manual

Postby eabrust » Sat Nov 02, 2019 2:24 am

Just some notes on things that worked and didn't work for me, as I'm learning as I go. Maybe this will help others:

1)
Converting the C# wrapper to VB via this website also had issues, similar to other conversion websites I tried. Any functions with 'unsafe' keyword failed to convert. Produced this sort of error
Code: Select all
    ' '''
    '        ''' Cannot convert MethodDeclarationSyntax, System.NotSupportedException: UnsafeKeyword is not supported!
    ' '''    at ICSharpCode.CodeConverter.VB.SyntaxKindExtensions.ConvertToken(SyntaxKind t, TokenContext context) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\VB\SyntaxKindExtensions.cs:line 186
    ' '''    at ICSharpCode.CodeConverter.VB.CommonConversions.ConvertModifier(SyntaxToken m, TokenContext context) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\VB\CommonConversions.cs:line 391
    ' '''    at ICSharpCode.CodeConverter.VB.CommonConversions.ConvertModifiersCore(IReadOnlyCollection`1 modifiers, TokenContext context, Boolean isConstructor)+MoveNext() in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\VB\CommonConversions.cs:line 349
    ' '''    at Microsoft.CodeAnalysis.SyntaxTokenList.CreateNode(IEnumerable`1 tokens)
    ' '''    at ICSharpCode.CodeConverter.VB.NodesVisitor.VisitMethodDeclaration(MethodDeclarationSyntax node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\VB\NodesVisitor.cs:line 407
    ' '''    at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.Visit(SyntaxNode node)
    ' '''    at ICSharpCode.CodeConverter.VB.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\VB\CommentConvertingNodesVisitor.cs:line 35
    ' '''     ' ''' Input:
    ' '''
    '    /// <summary>
    '    /// Returns the device properties defined by the boardID parameter. If the BoardID is lower or equals 0 then it is demo mode.
    '    /// </summary>
    '    /// <param name="BoardID">The ID of the board (Listdevices list number).</param>
    '    /// <param name="Type">Device type (DeviceType enum)</param>
    '    /// <param name="SerialNumber">Returns the serial number of the controller as an integer value. (Convert to hexadecimal to get the serial number in the correct format.)</param>
    '    /// <returns>ReturnVal, UC error code.</returns>
    '     [DllImport("UC100.dll", CallingConvention = CallingConvention.Cdecl)]
    '     unsafe public static extern int DeviceInfo(int BoardID, ref int Type, ref int SerialNumber);


~75% of the wrapper did convert to usable VB code, and I was able to use it successfully in a trial to access most of the API functions. I assume the remainder of functions that had the 'unsafe' keywork could be manually fixed, but I haven't quite figured out the corrections to make. I at least got access to all the functions that provide movement via VB instead of C# (AddLinearMoveP, AddLinearMove, etc).

2)
As a separate trial, I created just a C# dll project of just the wrapper file on its own, and compiled it into a dll of its own. I was able to reference this precompiled wrapper.dll in a VB project completely, but had to keep the separate wrapper.DLL in the base UCCCNC directory as a resource. But this at least gives 100% of all the functions available to a VB project.

3)
I tried to import the pre-compiled wrapper.dll into the VB project as an embedded resource binary (to omit needing the separate wrapper.dll floating around), but couldn't quite get it to work out (yet).

If it isn't a problem with CNCDrive, I'll post the partially converted VB version of the wrapper after a little cleanup and commenting out the items that were a problem for visual studio.

regards
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 357
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: API information / manual

Postby eabrust » Sat Nov 23, 2019 1:20 am

For reference, attached is a VB translated version of the UC100 API. It is not 100% complete compared to the C# version that ships w/ UCCNC releases, but the bulk of the functions that send commands to UCCNC did translate and are verified to work.

I currently use this in Visualstudio 2017 to code in VB.

regards
Eric
Attachments
VB UC100wrapper.zip
UC100 API Wrapper - converted to VB
(8.95 KiB) Downloaded 677 times
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 357
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA


Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 27 guests