Results 1 to 9 of 9

Thread: Epson ePOS SDK for Universal Windows Apps v2.9.2a

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Epson ePOS SDK for Universal Windows Apps v2.9.2a

    Hi.
    I'm trying to get the device status on an Epson tm-m30
    Apparently and from what I've read the title SDK requires W10 and also 12GB extra disk space.
    So I have 3 questions here.
    Has anyone worked with a similar printer and got the status without the SDK.
    I can see that the samples require these imports:
    using Epson.Epos.Epos2;
    using Epson.Epos.Epos2.Printer;
    I don't seem to find those in my PC even after I have installed the SDK. Can I somethow use just those and not have to update my PC to w10 (which ain't happening)
    Is there a way to get the printer status without having to install the SDK? I mean there is a status program in the Epson installation that works just fine but it's C++ and it's not a sample program, it's just the dll.
    I have also found this: http://www.vbforums.com/showthread.p...nter-in-VB-NET
    but it does not work. It says that I have unbalanced the stack or something. Also if I am not mistaken there is no way to get the status with WMI or Pinvoke as an idle printer (and without using the sdk or the provider dll or some other solution that is not .net related, cannot show the status).
    Any thoughts ?
    thanks.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  2. #2
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    Hi,

    see i f this helps, you have to add a Ref. to ..System.Management

    Code:
    Imports System.Management
    
    
    'Source found:
    'https://social.msdn.microsoft.com/Forums/vstudio/en-US/cc51dbe5-666b-4c14-ad3c-cdfc9ffff0b4/how-to-declare-a-specific-printer-status-as-a-variable?forum=vbgeneral
    
    Public Class Form1
    
        Private dtPrinterStatus As DataTable
        Private WithEvents mgmtWatcher As ManagementEventWatcher
    
        Private Enum PrinterStatus
            Other = 1
            Unknown = 2
            Idle = 3
            Printing = 4
            WarmingUp = 5
            StoppedPrinting = 6
            Offline = 7
        End Enum
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            dtPrinterStatus = New DataTable
            dtPrinterStatus.Columns.Add("Name", GetType(String))
            dtPrinterStatus.Columns.Add("Status", GetType(PrinterStatus))
    
            With DataGridView1
                .DataSource = dtPrinterStatus
                .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
            End With
    
            Dim strWQL As String
            Dim oSearcher As ManagementObjectSearcher
            Dim oPrinter As ManagementObject
            strWQL = "SELECT Name, PrinterStatus FROM Win32_Printer"
            oSearcher = New ManagementObjectSearcher(strWQL)
            For Each oPrinter In oSearcher.Get()
                dtPrinterStatus.Rows.Add(oPrinter("Name"), oPrinter("PrinterStatus"))
            Next
    
            Dim wqlQuery As WqlEventQuery
            strWQL = "SELECT * FROM __InstanceModificationEvent WITHIN 1 WHERE TargetInstance ISA ""Win32_Printer"""
            wqlQuery = New WqlEventQuery(strWQL)
            mgmtWatcher = New ManagementEventWatcher
            With mgmtWatcher
                .Query = wqlQuery
                AddHandler .EventArrived, AddressOf mgmtWatcher_EventArrived
                .Start()
            End With
        End Sub
    
        Private Sub mgmtWatcher_EventArrived(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs) Handles mgmtWatcher.EventArrived
            Dim oPrinter As ManagementBaseObject
            Dim dRow As DataRow
            oPrinter = e.NewEvent("TargetInstance")
            dRow = dtPrinterStatus.Select("Name = '" & oPrinter("Name") & "'")(0)
            dRow("Status") = oPrinter("PrinterStatus")
            dRow.AcceptChanges()
        End Sub
    End Class
    hth
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  3. #3

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    Hi.
    Not really working as I always get status 3 = idle. I have tried WMI before and read that it will not work as the printer must be in a working - printing state in order to get paper out from WMI.

    I've also tried with Pinvoke but I always get status = 2 .
    If anyone care to see the code:

    Code:
        <DllImport("winspool.drv", SetLastError:=True)>
        Public Shared Function GetPrinter(ByVal hPrinter As IntPtr, ByVal dwLevel As Int32, ByVal pPrinter As Object, ByVal dwBuf As Int32, ByRef dwNeeded As Int32) As Boolean
        End Function
    
    
        <DllImport("winspool.drv", SetLastError:=True, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.StdCall)>
        Private Shared Function GetPrinterData(ByVal hPrinter As IntPtr, ByVal pValueName As String, ByRef pType As UInteger, ByRef pData As UInt32, ByVal nSize As UInteger, ByRef pcbNeeded As UInteger) As UInteger
        End Function
    
    
        ' Private Declare Function GetPrinterData Lib "winspool.drv" (ByVal hPrinter As IntPtr, ByVal pValueName As String, ByRef pType As UInteger, ByRef pData As UInt32, ByVal nSize As UInteger, ByRef pcbNeeded As UInteger) As UInteger
    
    
        Private Declare Function OpenPrinter Lib "winspool.Drv" Alias "OpenPrinterA" (ByVal szPrinter As String, ByRef hPrinter As IntPtr, ByVal pDefault As Int32) As Boolean
    
     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
     
            Dim c As Boolean = IsPrinterReady("epsonm30")
        End Sub
    
    
     Public Function IsPrinterReady(ByRef PrinterName As String) As Boolean
            Dim hPrinter As Int32, pcbNeeded As Int32, PI6 As PRINTER_INFO_6
    
            If OpenPrinter(PrinterName, hPrinter, 0) Then
    
                Dim j As UInteger = GetPrinterData(hPrinter, "Error", 0, Nothing, 0, 0)
    
            
            '    hPrinter = ClosePrinter(hPrinter) : Debug.Assert(hPrinter) ' currently not working
            End If
        End Function
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  4. #4

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    From Microsoft:
    There is one fundamental premise that must be true to determine the state of a physical printer: the Spooler must be attempting to send a print job to the physical printer. This is the only time the state of the printer is reported by the port monitor. In addition, the most meaningful information may be reported in the status members of a JOB_INFO structure for that particular print job because some port monitor will have set these values directly.

    I'll try to send a print job and see if I get the correct status....


    Edit.
    Ok I get status = 2 . Marked as unknown. However I must be printing something to get a status so am Ito assume that without the SDK there is no way to get the paper out status without sending something to the spooler?

    Aaand if I print from another program that does not send a printer status it will just ignore and catch a status printing (probably the spooler has the data and it assumes it will print).
    Last edited by sapator; Feb 11th, 2019 at 09:21 AM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    What the...
    There is a deprecated property named "PrinterState"
    This will give out all the correct states of the printer.
    Again.WHAT THE?!!!!!!
    The marked it as deprecated and suggested to use "PrinterStatus" that does not have all the values that "PrinterState" has!
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  6. #6
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    Quote Originally Posted by sapator View Post
    Hi.
    Not really working as I always get status 3 = idle. I have tried WMI before and read that it will not work as the printer must be in a working - printing state in order to get paper out from WMI.
    [/CODE]
    I thought the same as you did, print a large File >50 pages
    and you will see it change from 'Idle' to 'Printing' , once finished it will go back to 'Idle'
    seems to print that fast you can't see it changing.

    add this for a Print Count
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            dtPrinterStatus = New DataTable
            dtPrinterStatus.Columns.Add("Name", GetType(String))
            dtPrinterStatus.Columns.Add("CurrentJobs", GetType(UInt32))
            dtPrinterStatus.Columns.Add("TotalJobsPrinted", GetType(UInt32))
    
            With DataGridView1
                .DataSource = dtPrinterStatus
                .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
            End With
    
            Dim strWQL As String
            Dim oSearcher As ManagementObjectSearcher
            Dim oPrinter As ManagementObject
            strWQL = "SELECT Name, Jobs,TotalJobsPrinted FROM Win32_PerfFormattedData_Spooler_PrintQueue"
            oSearcher = New ManagementObjectSearcher(strWQL)
            For Each oPrinter In oSearcher.Get()
                dtPrinterStatus.Rows.Add(oPrinter("Name"), oPrinter("Jobs"), oPrinter("TotalJobsPrinted"))
            Next
        End Sub
    or in Powershell for a count:
    Code:
    Get-WMIObject Win32_PerfFormattedData_Spooler_PrintQueue |
    Select Name, @{Expression={$_.jobs};Label="CurrentJobs"}, TotalJobsPrinted, JobErrors
    HTH
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  7. #7

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    Hey.
    See post n5
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  8. #8

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    Turn out that this will not work.
    There are some states of the printer that I can get. Open tray, paper out etc but I cannot get the most important step.
    If i start printing and the paper runs out then every WMI settins is suggesting that the printer is either on idle state or printing state.
    I don't know if this has to do with the printer or the spooler but WMI is out of the question for good.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  9. #9

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Epson ePOS SDK for Universal Windows Apps v2.9.2a

    Right.
    I have installed the epson SDK, it requested me to have W10 on visual studio. After laughing for about an hour I went and found a computer with W10.
    It installed something called "Universal_Windows_apps" . I'm not sure if it is the same bs it installed when we tried to use rasberry pi maybe maybe not, we deleted that thing a long time ago.
    So now I get the first using of epson " Epson.Epos.Epos2;" and it says the namespace Epson could not be found. I have installed every single setup found on Epson site and I cannot find the assembly anywhere. I googled and I only got one page with 6 articles. So this is a long shot by anyone have any idea?
    Thanks.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width