User Tools

Site Tools


data_core:tcpprinter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
data_core:tcpprinter [2023/11/15 11:39] sudata_core:tcpprinter [2024/05/24 14:39] (current) – [Verify TCP Port is in a listening state] su
Line 12: Line 12:
 Configure the Data Core TCP Printer driver to act as an Alarm & Event listener. Configure the Data Core TCP Printer driver to act as an Alarm & Event listener.
  
-  1. Open Data Core and navigate to: Alarms & Events > Event Sources+1. Open Data Core and navigate to: Alarms & Events > Event Sources
      
-  2. Create Event Source > Printer (TCP)+2. Create Event Source > Printer (TCP)
      
-  3. Provide a meaningful name and description, then configure the following key settings:+3. Provide a meaningful name and description, then configure the following key settings:
      
-    3.1 TCP Settings > TCP Port: (e.g. "9000"+3.1 TCP Settings > TCP Port: (e.g. "9000")
-    3.2 Printer Settings > Message Delimiter: (e.g. "<13><10" for carriage-return line-feed) +
-    3.3. Printer Settings > Trim Messages: (e.g. "False" if you wish to maintain line width and character +
-     positioning)+
  
-  4. Enable the printer by switching the Disabled status to "False".+3.2 Printer Settings > Message Delimiter: (e.g. "<13><10" for carriage-return line-feed) 
 + 
 +3.3. Printer Settings > Trim Messages: (e.g. "False" if you wish to maintain line width and character positioning) 
 +   
 +4. Enable the printer by switching the Disabled status to "False".
          
  
 ==== 2. Add a TCP Printer ==== ==== 2. Add a TCP Printer ====
  
-To write data to the Data Core TCP listener, register a new printer via Windows Settings+Configure a "Generic/Text Only" printer to output to the TCP Port defined above. This can be done manually via Windows Control Panel, or using the Powershell script below (amend as required). 
 + 
 +<code> 
 + 
 +# Register a Generic/TextOnly TCP printer 
 +  
 +# Define printer parameters 
 +$printerName = "Data Core TCP Printer" 
 +$printerPort = 9000 
 +$printerIPAddress = "127.0.0.1" 
 +$driverName = "Generic / Text Only" 
 + 
 +# Check if the printer already exists 
 +$existingPrinter = Get-Printer -Name $printerName -ErrorAction SilentlyContinue 
 + 
 +if ($existingPrinter -eq $null) { 
 +    # Create a new TCP/IP printer port 
 +    $tcpPort = "IP_$printerIPAddress" 
 +    Add-PrinterPort -Name $tcpPort -PrinterHostAddress $printerIPAddress -PortNumber $printerPort 
 + 
 +    # Add the printer using the TCP/IP port 
 +    Add-Printer -Name $printerName -PortName $tcpPort -DriverName: $driverName 
 + 
 +    Write-Host "Printer '$printerName' registered on IP $printerIPAddress and port $printerPort." 
 +} else { 
 +    Write-Host "Printer '$printerName' already exists.
 +
 + 
 +</code>
  
-  1. Open: Windows Settings > Printers & Scanners 
-   
-  2. Configure a local printer or network printer with manual settings: 
-   
-    2.1 Type of Port: Standard TCP/IP Port 
-    2.2 Device Type:  TCP/IP Device 
-    2.3 Hostname or IP Address: [e.g. 127.0.0.1] 
-    2.4 Port name: [Port should match data core config] 
-    2.5 Port protocol: Raw 
-    2.6 Manufacturer: Generic 
-    2.7 Printers: Generic / Text Only 
          
 ===== Testing ===== ===== Testing =====
Line 61: Line 79:
   3. Check both Admin and Operational Log   3. Check both Admin and Operational Log
  
-====Netstat====+====Verify TCP Port is in a listening state ====
  
-Confirm the port is in a listening state.+Use **NetStat** to confirm the port is in a listening state.
  
   1. Open cmd window   1. Open cmd window
Line 69: Line 87:
   3. Search content for configured port and check state   3. Search content for configured port and check state
  
-====Putty==== 
  
-A 3rd party connection testing tool such as Putty could be used to check the TCP listener.+**Send a message directly to the TCP Port** 
 + 
 +Try sending messages directly to the TCP port. If this works, the issue may be the printer configuration rather than the file content and/or the Data Core TCP listener.
  
-**Powershell**+Use a tool such as Putty, or the Powershell script below (amend as necessary).
  
-Try sending example files directly to the TCP port. If this works, the issue may be the printer configuration rather than the file content and/or the Data Core TCP listener. 
  
 <code> <code>
Line 100: Line 118:
         $Socket = New-Object System.Net.Sockets.TCPClient($Address,$Port)          $Socket = New-Object System.Net.Sockets.TCPClient($Address,$Port) 
          
-        # Setup stream wrtier +        # Setup stream writer 
         $Stream = $Socket.GetStream()          $Stream = $Socket.GetStream() 
         $Writer = New-Object System.IO.StreamWriter($Stream)         $Writer = New-Object System.IO.StreamWriter($Stream)
Line 117: Line 135:
  
 # Get all files in dirctory # Get all files in dirctory
-$dirPath = "C:\Temp\IthacaPrint"+$dirPath = "C:\Temp\PrintTest"
 $files = Get-ChildItem $dirPath | Where-Object { $_.PSIsContainer -eq $false } $files = Get-ChildItem $dirPath | Where-Object { $_.PSIsContainer -eq $false }
  
data_core/tcpprinter.txt · Last modified: 2024/05/24 14:39 by su