system.device.addDevice

According to the documentation, this function accepts several parameters.
When trying to add TCP devices with “Character Based” message delimiter type, I kept getting an exception:

>>> system.device.addDevice(driver="TCP", deviceName="test",messageDelimiterType='Character Based', hostname='127.0.0.1', ports='1000')
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Converting Character Based for [TCPDriverSettings null NewRecord Dirty1].[F TCPDriverSettings.MessageDelimiterType]

I found a different way to add the device with:
system.device.addDevice(deviceName='test', deviceType='TCPDriver', deviceProps=deviceProps)
and setting some options through the deviceProps dictionary.
I could not find any documentation for what parameters I can use in this dictionary so I tried this and got lucky:

deviceProps={
	'Ports': '1000',
	'Address': '127.0.0.1'
	'MessageDelimiterType': 'CharacterBased',
	'MessageDelimiter': '\x03'
	}

Does anybody know a full description of this parameter? What does it accept and what does it not?

I’m going to guess the values are driver-specific and correspond to the columns in that drivers settings table in the gateway’s internal database. In the raw settings viewer, this:

Select sql from sqlite_master where name='TCPDRIVERSETTINGS'

yields:

CREATE TABLE TCPDRIVERSETTINGS ( "DEVICESETTINGSID" NUMERIC(18,0) NOT NULL, "PORTS" VARCHAR(4096) NOT NULL, "ADDRESS" VARCHAR(4096) NOT NULL, "INACTIVITYTIMEOUT" INTEGER DEFAULT 0 NOT NULL, "MESSAGEDELIMITERTYPE" VARCHAR(1024) DEFAULT 'PacketBased', "MESSAGEDELIMITER" VARCHAR(4096), "FIELDCOUNT" INTEGER DEFAULT 0, "FIELDDELIMITER" VARCHAR(4096), "WRITEBACKENABLED" BOOLEAN DEFAULT 0, "WRITEBACKDELIMITER" VARCHAR(4096) DEFAULT '', CONSTRAINT PK_TCPDRIVERSETTINGS PRIMARY KEY (DEVICESETTINGSID) )

Ok, that’s some nice reverse engineering. :sunglasses:
Still those are the column names of the table, but I don’t know the mapping from the deviceProps dictionary to those columns.
Also, following your idea, I took a look at the “DeviceSettings” table and found DESCRIPTION and ENABLED there, but could not find the mapping from the addDevice parameters to those columns.
Still, thanks for your input, interesting way of finding out the innerworkings of Ignition.

Not that I’m allowed to condone this, but you actually want ‘TCPDRIVERSETTINGS’ in the IDB in this case.

That said, it looks like there’s a bug with the addDevice function (which isn’t surprising):

system.device.addDevice(
	driver="tcp",
	deviceName="test124",
	messageDelimiterType="Character Based",
	hostname='127.0.0.1', 
	ports='1000')

Throws an error GatewayException: Converting Character Based for [TCPDriverSettings null NewRecord Dirty1].[F TCPDriverSettings.MessageDelimiterType], but does successfully create a ‘Packet Based’ device on the gateway.

I’ve filed an internal ticket to get this looked at.

Great, thank you for that. Would you mind adding to the ticket that there is no way of modifying the Description of the device from the addDevice function as well?

@PGriffith,
About the system.device.addDevice, it would every usefull if you can add the device description parameter !